<!DOCTYPE html>
<!-- saved from url=(0087)https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support -->
<html class="hasSidebar hasPageActions hasBreadcrumb conceptual has-default-focus js-focus-visible theme-light mathjax-complete" lang="zh-cn" dir="ltr" data-css-variable-support="true" data-authenticated="false" data-auth-status-determined="true" data-target="docs" x-ms-format-detection="none" data-js-focus-visible=""><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta property="og:title" content="使用插件创建 .NET Core 应用程序 - .NET">
	<meta property="og:type" content="website">
	<meta property="og:url" content="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support">
			<meta property="og:description" content="了解如何创建支持插件的 .NET Core 应用程序。">
		<meta property="og:image" content="https://docs.microsoft.com/en-us/media/logos/logo-ms-social.png">
		<meta property="og:image:alt" content="Microsoft Logo">

	<meta name="twitter:card" content="summary">
	<meta name="twitter:site" content="@docsmsft">

	<meta name="color-scheme" content="light">


	<meta name="apiPlatform" content="dotnet">
<meta name="author" content="jkoritzinsky">
<meta name="bilingual_type" content="hover over">
<meta name="breadcrumb_path" content="/dotnet/breadcrumb/toc.json">
<meta name="depot_name" content="VS.core-docs">
<meta name="description" content="了解如何创建支持插件的 .NET Core 应用程序。">
<meta name="document_id" content="06023407-704f-0ace-e89a-eedd9f95a007">
<meta name="document_version_independent_id" content="f25a6e1a-cb10-867b-0522-a377bf9d016b">
<meta name="enable_loc_sxs" content="true">
<meta name="gitcommit" content="https://github.com/dotnet/docs.zh-cn/blob/afcd38ce885135bbe64ce059141da178c2074613/docs/core/tutorials/creating-app-with-plugin-support.md">
<meta name="locale" content="zh-cn">
<meta name="ms.author" content="jekoritz">
<meta name="ms.contentlocale" content="zh-CN">
<meta name="ms.date" content="10/16/2019">
<meta name="ms.devlang" content="dotnet">
<meta name="ms.lasthandoff" content="01/14/2021">
<meta name="ms.locfileid" content="98187894">
<meta name="ms.openlocfilehash" content="d3b532ae72a80eef9603fc6f3ada8c11cae966dd">
<meta name="ms.prod" content="dotnet-fundamentals">
<meta name="ms.sourcegitcommit" content="a4cecb7389f02c27e412b743f9189bd2a6dea4d6">
<meta name="ms.topic" content="tutorial">
<meta name="ms.translationtype" content="HT">
<meta name="original_content_git_url" content="https://github.com/dotnet/docs.zh-cn/blob/live-sxs/docs/core/tutorials/creating-app-with-plugin-support.md">
<meta name="search.ms_docsetname" content="core-docs">
<meta name="search.ms_product" content="VS">
<meta name="search.ms_sitename" content="Docs">
<meta name="show_latex" content="true">
<meta name="site_name" content="Docs">
<meta name="uhfHeaderId" content="MSDocsHeader-DotNet">
<meta name="updated_at" content="2021-01-22 06:29 AM">
<meta name="page_type" content="conceptual">
<meta name="toc_rel" content="../../fundamentals/toc.json">
<meta name="pdf_url_template" content="https://docs.microsoft.com/pdfstore/zh-cn/VS.core-docs/{branchName}{pdfName}">
<meta name="search.mshattr.devlang" content="csharp">
<meta name="word_count" content="4045">


	<meta name="scope" content=".NET">
<link href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support" rel="canonical">
	<title>使用插件创建 .NET Core 应用程序 - .NET | Microsoft Docs</title>

		<link rel="stylesheet" href="./使用插件创建 .NET Core 应用程序 - .NET _ Microsoft Docs_files/c4247d81.site-ltr.css">

	


	<script async="" defer="" crossorigin="anonymous" src="./使用插件创建 .NET Core 应用程序 - .NET _ Microsoft Docs_files/lux.js.下载"></script><script async="" src="./使用插件创建 .NET Core 应用程序 - .NET _ Microsoft Docs_files/analytics.js.下载"></script><script id="msdocs-script">
	var msDocs = {
		data: {
			timeOrigin: Date.now(),
			contentLocale: 'zh-cn',
			contentDir: 'ltr',
			userLocale: 'zh-cn',
			userDir: 'ltr',
			pageTemplate: 'Conceptual',
			brand: '',
			context: {

			},
			hasBinaryRating: true,
			hasGithubIssues: true,
			showFeedbackReport: false,
			enableTutorialFeedback: false,
			feedbackSystem: 'GitHub',
			feedbackGitHubRepo: 'dotnet/docs.zh-cn',
			feedbackProductUrl: 'https://aka.ms/feedback/report?space=61',
			contentGitUrl: 'https://github.com/dotnet/docs.zh-cn/blob/live/docs/core/tutorials/creating-app-with-plugin-support.md',
			extendBreadcrumb: false,
			isEditDisplayable: true,
			hideViewSource: false,
			hasPageActions: true,
			hasBookmark: true,
			hasShare: true,
			hasRecommendations: false,
			contributors: [
						{ name: "jkoritzinsky", url: "https://github.com/jkoritzinsky" },
						{ name: "olprod", url: "https://github.com/olprod" }
],
		},
		functions:{}
	};
	</script>
	<script src="./使用插件创建 .NET Core 应用程序 - .NET _ Microsoft Docs_files/wcp-consent.js.下载"></script>
	<script src="./使用插件创建 .NET Core 应用程序 - .NET _ Microsoft Docs_files/jsll-4.js.下载"></script>
	<script>window.jsllAwa = window.awa;</script>
	<script nomodule="" src="./使用插件创建 .NET Core 应用程序 - .NET _ Microsoft Docs_files/bluebird.min.js.下载" integrity="sha384-aD4BDeDGeLXLpPK4yKeqtZQa9dv4a/7mQ+4L5vwshIYH1Mc2BrXvHd32iHzYCQy5" crossorigin="anonymous"></script>
	<script nomodule="" src="./使用插件创建 .NET Core 应用程序 - .NET _ Microsoft Docs_files/fetch.umd.min.js.下载" integrity="sha384-EQIXrC5K2+7X8nGgLkB995I0/6jfAvvyG1ieZ+WYGxgJHFMD/alsG9fSDWvzb5Y1" crossorigin="anonymous"></script>
	<script nomodule="" src="./使用插件创建 .NET Core 应用程序 - .NET _ Microsoft Docs_files/template.min.js.下载" integrity="sha384-1zKzI6ldTVHMU7n0W2HpE/lhHI+UG4D9IIaxbj3kT2UhCWicdTuJkTtnKuu0CQzN" crossorigin="anonymous"></script>
	<script nomodule="" src="./使用插件创建 .NET Core 应用程序 - .NET _ Microsoft Docs_files/url.min.js.下载" integrity="sha384-vn7xBMtpSTfzaTRWxj0kVq0UcsbBrTOgZ/M1ISHqe1V358elYva+lfiEC+T8jLPc" crossorigin="anonymous"></script>
	<script src="./使用插件创建 .NET Core 应用程序 - .NET _ Microsoft Docs_files/f0a172e9.index-polyfills.js.下载"></script>
		<script src="./使用插件创建 .NET Core 应用程序 - .NET _ Microsoft Docs_files/qrious.min.js.下载" integrity="sha384-h/SmU/qxwYnRlzklg9PKWpDwyma9UmKuOB//Pz6Cov5KkEqcaFF0vod43/XhoeyJ" crossorigin="anonymous"></script>

		<script src="./使用插件创建 .NET Core 应用程序 - .NET _ Microsoft Docs_files/6a6ed3cd.index-docs.js.下载"></script><style></style>
<script async="" src="./使用插件创建 .NET Core 应用程序 - .NET _ Microsoft Docs_files/t.js.下载"></script><style type="text/css">.MathJax_Hover_Frame {border-radius: .25em; -webkit-border-radius: .25em; -moz-border-radius: .25em; -khtml-border-radius: .25em; box-shadow: 0px 0px 15px #83A; -webkit-box-shadow: 0px 0px 15px #83A; -moz-box-shadow: 0px 0px 15px #83A; -khtml-box-shadow: 0px 0px 15px #83A; border: 1px solid #A6D ! important; display: inline-block; position: absolute}
.MathJax_Menu_Button .MathJax_Hover_Arrow {position: absolute; cursor: pointer; display: inline-block; border: 2px solid #AAA; border-radius: 4px; -webkit-border-radius: 4px; -moz-border-radius: 4px; -khtml-border-radius: 4px; font-family: 'Courier New',Courier; font-size: 9px; color: #F0F0F0}
.MathJax_Menu_Button .MathJax_Hover_Arrow span {display: block; background-color: #AAA; border: 1px solid; border-radius: 3px; line-height: 0; padding: 4px}
.MathJax_Hover_Arrow:hover {color: white!important; border: 2px solid #CCC!important}
.MathJax_Hover_Arrow:hover span {background-color: #CCC!important}
</style><style type="text/css">#MathJax_About {position: fixed; left: 50%; width: auto; text-align: center; border: 3px outset; padding: 1em 2em; background-color: #DDDDDD; color: black; cursor: default; font-family: message-box; font-size: 120%; font-style: normal; text-indent: 0; text-transform: none; line-height: normal; letter-spacing: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; z-index: 201; border-radius: 15px; -webkit-border-radius: 15px; -moz-border-radius: 15px; -khtml-border-radius: 15px; box-shadow: 0px 10px 20px #808080; -webkit-box-shadow: 0px 10px 20px #808080; -moz-box-shadow: 0px 10px 20px #808080; -khtml-box-shadow: 0px 10px 20px #808080; filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='gray', Positive='true')}
#MathJax_About.MathJax_MousePost {outline: none}
.MathJax_Menu {position: absolute; background-color: white; color: black; width: auto; padding: 2px; border: 1px solid #CCCCCC; margin: 0; cursor: default; font: menu; text-align: left; text-indent: 0; text-transform: none; line-height: normal; letter-spacing: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; z-index: 201; box-shadow: 0px 10px 20px #808080; -webkit-box-shadow: 0px 10px 20px #808080; -moz-box-shadow: 0px 10px 20px #808080; -khtml-box-shadow: 0px 10px 20px #808080; filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='gray', Positive='true')}
.MathJax_MenuItem {padding: 2px 2em; background: transparent}
.MathJax_MenuArrow {position: absolute; right: .5em; padding-top: .25em; color: #666666; font-size: .75em}
.MathJax_MenuActive .MathJax_MenuArrow {color: white}
.MathJax_MenuArrow.RTL {left: .5em; right: auto}
.MathJax_MenuCheck {position: absolute; left: .7em}
.MathJax_MenuCheck.RTL {right: .7em; left: auto}
.MathJax_MenuRadioCheck {position: absolute; left: 1em}
.MathJax_MenuRadioCheck.RTL {right: 1em; left: auto}
.MathJax_MenuLabel {padding: 2px 2em 4px 1.33em; font-style: italic}
.MathJax_MenuRule {border-top: 1px solid #CCCCCC; margin: 4px 1px 0px}
.MathJax_MenuDisabled {color: GrayText}
.MathJax_MenuActive {background-color: Highlight; color: HighlightText}
.MathJax_MenuDisabled:focus, .MathJax_MenuLabel:focus {background-color: #E8E8E8}
.MathJax_ContextMenu:focus {outline: none}
.MathJax_ContextMenu .MathJax_MenuItem:focus {outline: none}
#MathJax_AboutClose {top: .2em; right: .2em}
.MathJax_Menu .MathJax_MenuClose {top: -10px; left: -10px}
.MathJax_MenuClose {position: absolute; cursor: pointer; display: inline-block; border: 2px solid #AAA; border-radius: 18px; -webkit-border-radius: 18px; -moz-border-radius: 18px; -khtml-border-radius: 18px; font-family: 'Courier New',Courier; font-size: 24px; color: #F0F0F0}
.MathJax_MenuClose span {display: block; background-color: #AAA; border: 1.5px solid; border-radius: 18px; -webkit-border-radius: 18px; -moz-border-radius: 18px; -khtml-border-radius: 18px; line-height: 0; padding: 8px 0 6px}
.MathJax_MenuClose:hover {color: white!important; border: 2px solid #CCC!important}
.MathJax_MenuClose:hover span {background-color: #CCC!important}
.MathJax_MenuClose:hover:focus {outline: none}
</style><style type="text/css">.MathJax_Preview .MJXf-math {color: inherit!important}
</style><style type="text/css">.MJX_Assistive_MathML {position: absolute!important; top: 0; left: 0; clip: rect(1px, 1px, 1px, 1px); padding: 1px 0 0 0!important; border: 0!important; height: 1px!important; width: 1px!important; overflow: hidden!important; display: block!important; -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none}
.MJX_Assistive_MathML.MJX_Assistive_MathML_Block {width: 100%!important}
</style><style type="text/css">#MathJax_Zoom {position: absolute; background-color: #F0F0F0; overflow: auto; display: block; z-index: 301; padding: .5em; border: 1px solid black; margin: 0; font-weight: normal; font-style: normal; text-align: left; text-indent: 0; text-transform: none; line-height: normal; letter-spacing: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; -webkit-box-sizing: content-box; -moz-box-sizing: content-box; box-sizing: content-box; box-shadow: 5px 5px 15px #AAAAAA; -webkit-box-shadow: 5px 5px 15px #AAAAAA; -moz-box-shadow: 5px 5px 15px #AAAAAA; -khtml-box-shadow: 5px 5px 15px #AAAAAA; filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='gray', Positive='true')}
#MathJax_ZoomOverlay {position: absolute; left: 0; top: 0; z-index: 300; display: inline-block; width: 100%; height: 100%; border: 0; padding: 0; margin: 0; background-color: white; opacity: 0; filter: alpha(opacity=0)}
#MathJax_ZoomFrame {position: relative; display: inline-block; height: 0; width: 0}
#MathJax_ZoomEventTrap {position: absolute; left: 0; top: 0; z-index: 302; display: inline-block; border: 0; padding: 0; margin: 0; background-color: white; opacity: 0; filter: alpha(opacity=0)}
</style><style type="text/css">.MathJax_Preview {color: #888}
#MathJax_Message {position: fixed; left: 1em; bottom: 1.5em; background-color: #E6E6E6; border: 1px solid #959595; margin: 0px; padding: 2px 8px; z-index: 102; color: black; font-size: 80%; width: auto; white-space: nowrap}
#MathJax_MSIE_Frame {position: absolute; top: 0; left: 0; width: 0px; z-index: 101; border: 0px; margin: 0px; padding: 0px}
.MathJax_Error {color: #CC0000; font-style: italic}
</style><style type="text/css">.MJXp-script {font-size: .8em}
.MJXp-right {-webkit-transform-origin: right; -moz-transform-origin: right; -ms-transform-origin: right; -o-transform-origin: right; transform-origin: right}
.MJXp-bold {font-weight: bold}
.MJXp-italic {font-style: italic}
.MJXp-scr {font-family: MathJax_Script,'Times New Roman',Times,STIXGeneral,serif}
.MJXp-frak {font-family: MathJax_Fraktur,'Times New Roman',Times,STIXGeneral,serif}
.MJXp-sf {font-family: MathJax_SansSerif,'Times New Roman',Times,STIXGeneral,serif}
.MJXp-cal {font-family: MathJax_Caligraphic,'Times New Roman',Times,STIXGeneral,serif}
.MJXp-mono {font-family: MathJax_Typewriter,'Times New Roman',Times,STIXGeneral,serif}
.MJXp-largeop {font-size: 150%}
.MJXp-largeop.MJXp-int {vertical-align: -.2em}
.MJXp-math {display: inline-block; line-height: 1.2; text-indent: 0; font-family: 'Times New Roman',Times,STIXGeneral,serif; white-space: nowrap; border-collapse: collapse}
.MJXp-display {display: block; text-align: center; margin: 1em 0}
.MJXp-math span {display: inline-block}
.MJXp-box {display: block!important; text-align: center}
.MJXp-box:after {content: " "}
.MJXp-rule {display: block!important; margin-top: .1em}
.MJXp-char {display: block!important}
.MJXp-mo {margin: 0 .15em}
.MJXp-mfrac {margin: 0 .125em; vertical-align: .25em}
.MJXp-denom {display: inline-table!important; width: 100%}
.MJXp-denom > * {display: table-row!important}
.MJXp-surd {vertical-align: top}
.MJXp-surd > * {display: block!important}
.MJXp-script-box > *  {display: table!important; height: 50%}
.MJXp-script-box > * > * {display: table-cell!important; vertical-align: top}
.MJXp-script-box > *:last-child > * {vertical-align: bottom}
.MJXp-script-box > * > * > * {display: block!important}
.MJXp-mphantom {visibility: hidden}
.MJXp-munderover {display: inline-table!important}
.MJXp-over {display: inline-block!important; text-align: center}
.MJXp-over > * {display: block!important}
.MJXp-munderover > * {display: table-row!important}
.MJXp-mtable {vertical-align: .25em; margin: 0 .125em}
.MJXp-mtable > * {display: inline-table!important; vertical-align: middle}
.MJXp-mtr {display: table-row!important}
.MJXp-mtd {display: table-cell!important; text-align: center; padding: .5em 0 0 .5em}
.MJXp-mtr > .MJXp-mtd:first-child {padding-left: 0}
.MJXp-mtr:first-child > .MJXp-mtd {padding-top: 0}
.MJXp-mlabeledtr {display: table-row!important}
.MJXp-mlabeledtr > .MJXp-mtd:first-child {padding-left: 0}
.MJXp-mlabeledtr:first-child > .MJXp-mtd {padding-top: 0}
.MJXp-merror {background-color: #FFFF88; color: #CC0000; border: 1px solid #CC0000; padding: 1px 3px; font-style: normal; font-size: 90%}
.MJXp-scale0 {-webkit-transform: scaleX(.0); -moz-transform: scaleX(.0); -ms-transform: scaleX(.0); -o-transform: scaleX(.0); transform: scaleX(.0)}
.MJXp-scale1 {-webkit-transform: scaleX(.1); -moz-transform: scaleX(.1); -ms-transform: scaleX(.1); -o-transform: scaleX(.1); transform: scaleX(.1)}
.MJXp-scale2 {-webkit-transform: scaleX(.2); -moz-transform: scaleX(.2); -ms-transform: scaleX(.2); -o-transform: scaleX(.2); transform: scaleX(.2)}
.MJXp-scale3 {-webkit-transform: scaleX(.3); -moz-transform: scaleX(.3); -ms-transform: scaleX(.3); -o-transform: scaleX(.3); transform: scaleX(.3)}
.MJXp-scale4 {-webkit-transform: scaleX(.4); -moz-transform: scaleX(.4); -ms-transform: scaleX(.4); -o-transform: scaleX(.4); transform: scaleX(.4)}
.MJXp-scale5 {-webkit-transform: scaleX(.5); -moz-transform: scaleX(.5); -ms-transform: scaleX(.5); -o-transform: scaleX(.5); transform: scaleX(.5)}
.MJXp-scale6 {-webkit-transform: scaleX(.6); -moz-transform: scaleX(.6); -ms-transform: scaleX(.6); -o-transform: scaleX(.6); transform: scaleX(.6)}
.MJXp-scale7 {-webkit-transform: scaleX(.7); -moz-transform: scaleX(.7); -ms-transform: scaleX(.7); -o-transform: scaleX(.7); transform: scaleX(.7)}
.MJXp-scale8 {-webkit-transform: scaleX(.8); -moz-transform: scaleX(.8); -ms-transform: scaleX(.8); -o-transform: scaleX(.8); transform: scaleX(.8)}
.MJXp-scale9 {-webkit-transform: scaleX(.9); -moz-transform: scaleX(.9); -ms-transform: scaleX(.9); -o-transform: scaleX(.9); transform: scaleX(.9)}
.MathJax_PHTML .noError {vertical-align: ; font-size: 90%; text-align: left; color: black; padding: 1px 3px; border: 1px solid}
</style><script async="" src="./使用插件创建 .NET Core 应用程序 - .NET _ Microsoft Docs_files/t.js(1).下载"></script><script async="" src="./使用插件创建 .NET Core 应用程序 - .NET _ Microsoft Docs_files/t.js(2).下载"></script><script async="" src="./使用插件创建 .NET Core 应用程序 - .NET _ Microsoft Docs_files/t.js(3).下载"></script><script async="" src="./使用插件创建 .NET Core 应用程序 - .NET _ Microsoft Docs_files/t.js(4).下载"></script><script async="" src="https://web.vortex.data.microsoft.com/collect/v1/t.js?ver=%272.1%27&amp;name=%27Ms.Webi.PageAction%27&amp;time=%272021-03-18T05%3A59%3A45.364Z%27&amp;os=%27Windows%27&amp;appId=%27JS%3ADocs%27&amp;-ver=%271.0%27&amp;-impressionGuid=%27534a860f-07e3-4c79-af03-6704eacf159e%27&amp;-pageName=%2706023407-704f-0ace-e89a-eedd9f95a007%27&amp;-uri=%27https%3A%2F%2Fdocs.microsoft.com%2Fzh-cn%2Fdotnet%2Fcore%2Ftutorials%2Fcreating-app-with-plugin-support%27&amp;-pageTags=%27%7B%22author%22%3A%22jkoritzinsky%22%2C%22depotname%22%3A%22VS.core-docs%22%2C%22document_version_independent_id%22%3A%22f25a6e1a-cb10-867b-0522-a377bf9d016b%22%2C%22gitcommit%22%3A%22https%3A%2F%2Fgithub.com%2Fdotnet%2Fdocs.zh-cn%2Fblob%2Fafcd38ce885135bbe64ce059141da178c2074613%2Fdocs%2Fcore%2Ftutorials%2Fcreating-app-with-plugin-support.md%22%2C%22pgauth%22%3A%22jekoritz%22%2C%22date%22%3A%2210%2F16%2F2019%22%2C%22pgdevlng%22%3A%22dotnet%22%2C%22lasthandoff%22%3A%2201%2F14%2F2021%22%2C%22locfileid%22%3A%2298187894%22%2C%22product%22%3A%22dotnet-fundamentals%22%2C%22pgtop%22%3A%22tutorial%22%2C%22translationtype%22%3A%22HT%22%2C%22giturl%22%3A%22https%3A%2F%2Fgithub.com%2Fdotnet%2Fdocs.zh-cn%2Fblob%2Flive-sxs%2Fdocs%2Fcore%2Ftutorials%2Fcreating-app-with-plugin-support.md%22%2C%22publishtime%22%3A%222021-01-22%2006%3A29%20AM%22%2C%22contentlocale%22%3A%22zh-cn%22%2C%22highContrast%22%3A%22false%22%2C%22metaTags%22%3A%7B%7D%7D%27&amp;-contentVer=%272.0%27&amp;-market=%27zh-cn%27&amp;-pageType=%27conceptual%27&amp;-actionType=%27O%27&amp;-behavior=300&amp;-content=%27%5B%7B%22event%22%3A%22page-focus-changed%22%2C%22value%22%3A%22blur%22%7D%5D%27&amp;*baseType=%27Ms.Content.PageAction%27&amp;*timeToAction=10629&amp;*cookieEnabled=true&amp;*isJs=true&amp;*title=%27%E4%BD%BF%E7%94%A8%E6%8F%92%E4%BB%B6%E5%88%9B%E5%BB%BA%20.NET%20Core%20%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%20-%20.NET%20%7C%20Microsoft%20Docs%27&amp;*isLoggedIn=false&amp;*isManual=true&amp;ext-javascript-ver=%271.1%27&amp;ext-javascript-libVer=%274.3.4%27&amp;ext-javascript-domain=%27docs.microsoft.com%27&amp;ext-javascript-msfpc=%27GUID%3Dbe533a6349374a19a3147b6350f4741a%26HASH%3Dbe53%26LV%3D202102%26V%3D4%26LU%3D1614099774713%27&amp;ext-javascript-userConsent=true&amp;ext-user-localId=%27t%3A01CDCD9B69DF681D0993C27C6DDF6E74%27&amp;$mscomCookies=false"></script><script async="" src="https://web.vortex.data.microsoft.com/collect/v1/t.js?ver=%272.1%27&amp;name=%27Ms.Webi.PageAction%27&amp;time=%272021-03-18T06%3A00%3A18.298Z%27&amp;os=%27Windows%27&amp;appId=%27JS%3ADocs%27&amp;-ver=%271.0%27&amp;-impressionGuid=%27534a860f-07e3-4c79-af03-6704eacf159e%27&amp;-pageName=%2706023407-704f-0ace-e89a-eedd9f95a007%27&amp;-uri=%27https%3A%2F%2Fdocs.microsoft.com%2Fzh-cn%2Fdotnet%2Fcore%2Ftutorials%2Fcreating-app-with-plugin-support%27&amp;-pageTags=%27%7B%22author%22%3A%22jkoritzinsky%22%2C%22depotname%22%3A%22VS.core-docs%22%2C%22document_version_independent_id%22%3A%22f25a6e1a-cb10-867b-0522-a377bf9d016b%22%2C%22gitcommit%22%3A%22https%3A%2F%2Fgithub.com%2Fdotnet%2Fdocs.zh-cn%2Fblob%2Fafcd38ce885135bbe64ce059141da178c2074613%2Fdocs%2Fcore%2Ftutorials%2Fcreating-app-with-plugin-support.md%22%2C%22pgauth%22%3A%22jekoritz%22%2C%22date%22%3A%2210%2F16%2F2019%22%2C%22pgdevlng%22%3A%22dotnet%22%2C%22lasthandoff%22%3A%2201%2F14%2F2021%22%2C%22locfileid%22%3A%2298187894%22%2C%22product%22%3A%22dotnet-fundamentals%22%2C%22pgtop%22%3A%22tutorial%22%2C%22translationtype%22%3A%22HT%22%2C%22giturl%22%3A%22https%3A%2F%2Fgithub.com%2Fdotnet%2Fdocs.zh-cn%2Fblob%2Flive-sxs%2Fdocs%2Fcore%2Ftutorials%2Fcreating-app-with-plugin-support.md%22%2C%22publishtime%22%3A%222021-01-22%2006%3A29%20AM%22%2C%22contentlocale%22%3A%22zh-cn%22%2C%22highContrast%22%3A%22false%22%2C%22metaTags%22%3A%7B%7D%7D%27&amp;-contentVer=%272.0%27&amp;-market=%27zh-cn%27&amp;-pageType=%27conceptual%27&amp;-actionType=%27O%27&amp;-behavior=300&amp;-content=%27%5B%7B%22event%22%3A%22page-visibility-changed%22%2C%22value%22%3A%22hidden%22%7D%5D%27&amp;*baseType=%27Ms.Content.PageAction%27&amp;*timeToAction=43563&amp;*cookieEnabled=true&amp;*isJs=true&amp;*title=%27%E4%BD%BF%E7%94%A8%E6%8F%92%E4%BB%B6%E5%88%9B%E5%BB%BA%20.NET%20Core%20%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%20-%20.NET%20%7C%20Microsoft%20Docs%27&amp;*isLoggedIn=false&amp;*isManual=true&amp;ext-javascript-ver=%271.1%27&amp;ext-javascript-libVer=%274.3.4%27&amp;ext-javascript-domain=%27docs.microsoft.com%27&amp;ext-javascript-msfpc=%27GUID%3Dbe533a6349374a19a3147b6350f4741a%26HASH%3Dbe53%26LV%3D202102%26V%3D4%26LU%3D1614099774713%27&amp;ext-javascript-userConsent=true&amp;ext-user-localId=%27t%3A01CDCD9B69DF681D0993C27C6DDF6E74%27&amp;$mscomCookies=false"></script><script async="" src="https://web.vortex.data.microsoft.com/collect/v1/t.js?ver=%272.1%27&amp;name=%27Ms.Webi.PageAction%27&amp;time=%272021-03-18T06%3A00%3A19.876Z%27&amp;os=%27Windows%27&amp;appId=%27JS%3ADocs%27&amp;-ver=%271.0%27&amp;-impressionGuid=%27534a860f-07e3-4c79-af03-6704eacf159e%27&amp;-pageName=%2706023407-704f-0ace-e89a-eedd9f95a007%27&amp;-uri=%27https%3A%2F%2Fdocs.microsoft.com%2Fzh-cn%2Fdotnet%2Fcore%2Ftutorials%2Fcreating-app-with-plugin-support%27&amp;-pageTags=%27%7B%22author%22%3A%22jkoritzinsky%22%2C%22depotname%22%3A%22VS.core-docs%22%2C%22document_version_independent_id%22%3A%22f25a6e1a-cb10-867b-0522-a377bf9d016b%22%2C%22gitcommit%22%3A%22https%3A%2F%2Fgithub.com%2Fdotnet%2Fdocs.zh-cn%2Fblob%2Fafcd38ce885135bbe64ce059141da178c2074613%2Fdocs%2Fcore%2Ftutorials%2Fcreating-app-with-plugin-support.md%22%2C%22pgauth%22%3A%22jekoritz%22%2C%22date%22%3A%2210%2F16%2F2019%22%2C%22pgdevlng%22%3A%22dotnet%22%2C%22lasthandoff%22%3A%2201%2F14%2F2021%22%2C%22locfileid%22%3A%2298187894%22%2C%22product%22%3A%22dotnet-fundamentals%22%2C%22pgtop%22%3A%22tutorial%22%2C%22translationtype%22%3A%22HT%22%2C%22giturl%22%3A%22https%3A%2F%2Fgithub.com%2Fdotnet%2Fdocs.zh-cn%2Fblob%2Flive-sxs%2Fdocs%2Fcore%2Ftutorials%2Fcreating-app-with-plugin-support.md%22%2C%22publishtime%22%3A%222021-01-22%2006%3A29%20AM%22%2C%22contentlocale%22%3A%22zh-cn%22%2C%22highContrast%22%3A%22false%22%2C%22metaTags%22%3A%7B%7D%7D%27&amp;-contentVer=%272.0%27&amp;-market=%27zh-cn%27&amp;-pageType=%27conceptual%27&amp;-actionType=%27O%27&amp;-behavior=300&amp;-content=%27%5B%7B%22event%22%3A%22page-visibility-changed%22%2C%22value%22%3A%22visible%22%7D%5D%27&amp;*baseType=%27Ms.Content.PageAction%27&amp;*timeToAction=45141&amp;*cookieEnabled=true&amp;*isJs=true&amp;*title=%27%E4%BD%BF%E7%94%A8%E6%8F%92%E4%BB%B6%E5%88%9B%E5%BB%BA%20.NET%20Core%20%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%20-%20.NET%20%7C%20Microsoft%20Docs%27&amp;*isLoggedIn=false&amp;*isManual=true&amp;ext-javascript-ver=%271.1%27&amp;ext-javascript-libVer=%274.3.4%27&amp;ext-javascript-domain=%27docs.microsoft.com%27&amp;ext-javascript-msfpc=%27GUID%3Dbe533a6349374a19a3147b6350f4741a%26HASH%3Dbe53%26LV%3D202102%26V%3D4%26LU%3D1614099774713%27&amp;ext-javascript-userConsent=true&amp;ext-user-localId=%27t%3A01CDCD9B69DF681D0993C27C6DDF6E74%27&amp;$mscomCookies=false"></script><script async="" src="https://web.vortex.data.microsoft.com/collect/v1/t.js?ver=%272.1%27&amp;name=%27Ms.Webi.PageAction%27&amp;time=%272021-03-18T06%3A00%3A19.918Z%27&amp;os=%27Windows%27&amp;appId=%27JS%3ADocs%27&amp;-ver=%271.0%27&amp;-impressionGuid=%27534a860f-07e3-4c79-af03-6704eacf159e%27&amp;-pageName=%2706023407-704f-0ace-e89a-eedd9f95a007%27&amp;-uri=%27https%3A%2F%2Fdocs.microsoft.com%2Fzh-cn%2Fdotnet%2Fcore%2Ftutorials%2Fcreating-app-with-plugin-support%27&amp;-pageTags=%27%7B%22author%22%3A%22jkoritzinsky%22%2C%22depotname%22%3A%22VS.core-docs%22%2C%22document_version_independent_id%22%3A%22f25a6e1a-cb10-867b-0522-a377bf9d016b%22%2C%22gitcommit%22%3A%22https%3A%2F%2Fgithub.com%2Fdotnet%2Fdocs.zh-cn%2Fblob%2Fafcd38ce885135bbe64ce059141da178c2074613%2Fdocs%2Fcore%2Ftutorials%2Fcreating-app-with-plugin-support.md%22%2C%22pgauth%22%3A%22jekoritz%22%2C%22date%22%3A%2210%2F16%2F2019%22%2C%22pgdevlng%22%3A%22dotnet%22%2C%22lasthandoff%22%3A%2201%2F14%2F2021%22%2C%22locfileid%22%3A%2298187894%22%2C%22product%22%3A%22dotnet-fundamentals%22%2C%22pgtop%22%3A%22tutorial%22%2C%22translationtype%22%3A%22HT%22%2C%22giturl%22%3A%22https%3A%2F%2Fgithub.com%2Fdotnet%2Fdocs.zh-cn%2Fblob%2Flive-sxs%2Fdocs%2Fcore%2Ftutorials%2Fcreating-app-with-plugin-support.md%22%2C%22publishtime%22%3A%222021-01-22%2006%3A29%20AM%22%2C%22contentlocale%22%3A%22zh-cn%22%2C%22highContrast%22%3A%22false%22%2C%22metaTags%22%3A%7B%7D%7D%27&amp;-contentVer=%272.0%27&amp;-market=%27zh-cn%27&amp;-pageType=%27conceptual%27&amp;-actionType=%27O%27&amp;-behavior=300&amp;-content=%27%5B%7B%22event%22%3A%22page-focus-changed%22%2C%22value%22%3A%22focus%22%7D%5D%27&amp;*baseType=%27Ms.Content.PageAction%27&amp;*timeToAction=45182&amp;*cookieEnabled=true&amp;*isJs=true&amp;*title=%27%E4%BD%BF%E7%94%A8%E6%8F%92%E4%BB%B6%E5%88%9B%E5%BB%BA%20.NET%20Core%20%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%20-%20.NET%20%7C%20Microsoft%20Docs%27&amp;*isLoggedIn=false&amp;*isManual=true&amp;ext-javascript-ver=%271.1%27&amp;ext-javascript-libVer=%274.3.4%27&amp;ext-javascript-domain=%27docs.microsoft.com%27&amp;ext-javascript-msfpc=%27GUID%3Dbe533a6349374a19a3147b6350f4741a%26HASH%3Dbe53%26LV%3D202102%26V%3D4%26LU%3D1614099774713%27&amp;ext-javascript-userConsent=true&amp;ext-user-localId=%27t%3A01CDCD9B69DF681D0993C27C6DDF6E74%27&amp;$mscomCookies=false"></script><script async="" src="https://web.vortex.data.microsoft.com/collect/v1/t.js?ver=%272.1%27&amp;name=%27Ms.Webi.PageAction%27&amp;time=%272021-03-18T06%3A00%3A21.555Z%27&amp;os=%27Windows%27&amp;appId=%27JS%3ADocs%27&amp;-ver=%271.0%27&amp;-impressionGuid=%27534a860f-07e3-4c79-af03-6704eacf159e%27&amp;-pageName=%2706023407-704f-0ace-e89a-eedd9f95a007%27&amp;-uri=%27https%3A%2F%2Fdocs.microsoft.com%2Fzh-cn%2Fdotnet%2Fcore%2Ftutorials%2Fcreating-app-with-plugin-support%27&amp;-pageTags=%27%7B%22author%22%3A%22jkoritzinsky%22%2C%22depotname%22%3A%22VS.core-docs%22%2C%22document_version_independent_id%22%3A%22f25a6e1a-cb10-867b-0522-a377bf9d016b%22%2C%22gitcommit%22%3A%22https%3A%2F%2Fgithub.com%2Fdotnet%2Fdocs.zh-cn%2Fblob%2Fafcd38ce885135bbe64ce059141da178c2074613%2Fdocs%2Fcore%2Ftutorials%2Fcreating-app-with-plugin-support.md%22%2C%22pgauth%22%3A%22jekoritz%22%2C%22date%22%3A%2210%2F16%2F2019%22%2C%22pgdevlng%22%3A%22dotnet%22%2C%22lasthandoff%22%3A%2201%2F14%2F2021%22%2C%22locfileid%22%3A%2298187894%22%2C%22product%22%3A%22dotnet-fundamentals%22%2C%22pgtop%22%3A%22tutorial%22%2C%22translationtype%22%3A%22HT%22%2C%22giturl%22%3A%22https%3A%2F%2Fgithub.com%2Fdotnet%2Fdocs.zh-cn%2Fblob%2Flive-sxs%2Fdocs%2Fcore%2Ftutorials%2Fcreating-app-with-plugin-support.md%22%2C%22publishtime%22%3A%222021-01-22%2006%3A29%20AM%22%2C%22contentlocale%22%3A%22zh-cn%22%2C%22highContrast%22%3A%22false%22%2C%22metaTags%22%3A%7B%7D%7D%27&amp;-contentVer=%272.0%27&amp;-market=%27zh-cn%27&amp;-pageType=%27conceptual%27&amp;-actionType=%27O%27&amp;-behavior=300&amp;-content=%27%5B%7B%22event%22%3A%22page-visibility-changed%22%2C%22value%22%3A%22hidden%22%7D%5D%27&amp;*baseType=%27Ms.Content.PageAction%27&amp;*timeToAction=46820&amp;*cookieEnabled=true&amp;*isJs=true&amp;*title=%27%E4%BD%BF%E7%94%A8%E6%8F%92%E4%BB%B6%E5%88%9B%E5%BB%BA%20.NET%20Core%20%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%20-%20.NET%20%7C%20Microsoft%20Docs%27&amp;*isLoggedIn=false&amp;*isManual=true&amp;ext-javascript-ver=%271.1%27&amp;ext-javascript-libVer=%274.3.4%27&amp;ext-javascript-domain=%27docs.microsoft.com%27&amp;ext-javascript-msfpc=%27GUID%3Dbe533a6349374a19a3147b6350f4741a%26HASH%3Dbe53%26LV%3D202102%26V%3D4%26LU%3D1614099774713%27&amp;ext-javascript-userConsent=true&amp;ext-user-localId=%27t%3A01CDCD9B69DF681D0993C27C6DDF6E74%27&amp;$mscomCookies=false"></script><script async="" src="https://web.vortex.data.microsoft.com/collect/v1/t.js?ver=%272.1%27&amp;name=%27Ms.Webi.PageAction%27&amp;time=%272021-03-18T06%3A00%3A22.047Z%27&amp;os=%27Windows%27&amp;appId=%27JS%3ADocs%27&amp;-ver=%271.0%27&amp;-impressionGuid=%27534a860f-07e3-4c79-af03-6704eacf159e%27&amp;-pageName=%2706023407-704f-0ace-e89a-eedd9f95a007%27&amp;-uri=%27https%3A%2F%2Fdocs.microsoft.com%2Fzh-cn%2Fdotnet%2Fcore%2Ftutorials%2Fcreating-app-with-plugin-support%27&amp;-pageTags=%27%7B%22author%22%3A%22jkoritzinsky%22%2C%22depotname%22%3A%22VS.core-docs%22%2C%22document_version_independent_id%22%3A%22f25a6e1a-cb10-867b-0522-a377bf9d016b%22%2C%22gitcommit%22%3A%22https%3A%2F%2Fgithub.com%2Fdotnet%2Fdocs.zh-cn%2Fblob%2Fafcd38ce885135bbe64ce059141da178c2074613%2Fdocs%2Fcore%2Ftutorials%2Fcreating-app-with-plugin-support.md%22%2C%22pgauth%22%3A%22jekoritz%22%2C%22date%22%3A%2210%2F16%2F2019%22%2C%22pgdevlng%22%3A%22dotnet%22%2C%22lasthandoff%22%3A%2201%2F14%2F2021%22%2C%22locfileid%22%3A%2298187894%22%2C%22product%22%3A%22dotnet-fundamentals%22%2C%22pgtop%22%3A%22tutorial%22%2C%22translationtype%22%3A%22HT%22%2C%22giturl%22%3A%22https%3A%2F%2Fgithub.com%2Fdotnet%2Fdocs.zh-cn%2Fblob%2Flive-sxs%2Fdocs%2Fcore%2Ftutorials%2Fcreating-app-with-plugin-support.md%22%2C%22publishtime%22%3A%222021-01-22%2006%3A29%20AM%22%2C%22contentlocale%22%3A%22zh-cn%22%2C%22highContrast%22%3A%22false%22%2C%22metaTags%22%3A%7B%7D%7D%27&amp;-contentVer=%272.0%27&amp;-market=%27zh-cn%27&amp;-pageType=%27conceptual%27&amp;-actionType=%27O%27&amp;-behavior=300&amp;-content=%27%5B%7B%22event%22%3A%22page-focus-changed%22%2C%22value%22%3A%22blur%22%7D%5D%27&amp;*baseType=%27Ms.Content.PageAction%27&amp;*timeToAction=47311&amp;*cookieEnabled=true&amp;*isJs=true&amp;*title=%27%E4%BD%BF%E7%94%A8%E6%8F%92%E4%BB%B6%E5%88%9B%E5%BB%BA%20.NET%20Core%20%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%20-%20.NET%20%7C%20Microsoft%20Docs%27&amp;*isLoggedIn=false&amp;*isManual=true&amp;ext-javascript-ver=%271.1%27&amp;ext-javascript-libVer=%274.3.4%27&amp;ext-javascript-domain=%27docs.microsoft.com%27&amp;ext-javascript-msfpc=%27GUID%3Dbe533a6349374a19a3147b6350f4741a%26HASH%3Dbe53%26LV%3D202102%26V%3D4%26LU%3D1614099774713%27&amp;ext-javascript-userConsent=true&amp;ext-user-localId=%27t%3A01CDCD9B69DF681D0993C27C6DDF6E74%27&amp;$mscomCookies=false"></script></head>

<body lang="zh-cn" dir="ltr"><div id="MathJax_Message" style="display: none;"></div><div style="display: none;" id="lightningjs-usabilla_live"><div><iframe frameborder="0" id="lightningjs-frame-usabilla_live" src="./使用插件创建 .NET Core 应用程序 - .NET _ Microsoft Docs_files/saved_resource.html"></iframe></div></div>
	<div class="header-holder has-default-focus">
		<a href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#main" class="skip-to-main-link has-outline-color-text visually-hidden-until-focused is-fixed has-inner-focus focus-visible has-top-zero has-left-zero has-right-zero has-padding-medium has-text-centered has-body-background-medium" tabindex="1">跳转至主内容</a>
		
		<div id="ignite-banner-holder" class="has-default-focus has-overflow-hidden"></div>
		
		<div hidden="" id="cookie-consent-holder"></div>
		<!-- liquid-tag banners global -->
		<div id="headerAreaHolder" data-bi-name="header">
<header role="banner" itemscope="itemscope" itemtype="http://schema.org/Organization"><!----> <div class="nav-bar"><!---->  <div class="nav-bar-brand">
		<a class="nav-bar-button" itemprop="url" href="https://www.microsoft.com/" aria-label="Microsoft">
			<div class="nav-bar-logo" role="presentation" aria-hidden="true" itemprop="logo" itemscope="itemscope">
				<svg xmlns="http://www.w3.org/2000/svg" width="108" height="23" viewBox="72 72 337 74" preserveAspectRatio="xMidYMin slice">
					<g data-name="MS-symbol">
						<clippath id="a">
							<path transform="matrix(1 0 0 -1 0 216)" d="M0 216h482V0H0z"></path>
						</clippath>
						<g clip-path="url(#a)">
							<path class="has-fill-current-color has-text-subtle" d="M394.942 104.59h-10.858v25.003h-7.38V104.59h-5.182v-5.965h5.182v-4.308c0-3.254 1.06-5.92 3.178-7.998 2.12-2.079 4.835-3.118 8.15-3.118.882 0 1.666.045 2.35.135a9.37 9.37 0 011.806.407v6.296c-.24-.14-.663-.31-1.265-.512-.603-.2-1.296-.3-2.078-.3-1.528 0-2.702.476-3.526 1.43-.824.954-1.235 2.365-1.235 4.232v3.736h10.858v-6.959l7.321-2.229v9.188h7.381v5.965h-7.38v14.49c0 1.91.345 3.254 1.038 4.037.693.783 1.782 1.175 3.27 1.175.42 0 .927-.1 1.52-.3a7.178 7.178 0 001.552-.724v6.025c-.463.261-1.23.502-2.305.723a15.742 15.742 0 01-3.178.331c-3.073 0-5.378-.817-6.914-2.455-1.537-1.637-2.305-4.102-2.305-7.396zm-48.407 9.73c0 3.233.733 5.703 2.2 7.411 1.465 1.707 3.564 2.56 6.295 2.56 2.652 0 4.67-.853 6.055-2.56 1.386-1.708 2.08-4.238 2.08-7.592 0-3.334-.719-5.849-2.155-7.547-1.436-1.697-3.45-2.545-6.04-2.545-2.67 0-4.745.888-6.22 2.666-1.477 1.777-2.215 4.313-2.215 7.607m-7.592.24c0-5.12 1.446-9.177 4.338-12.17 2.892-2.993 6.91-4.489 12.05-4.489 4.841 0 8.621 1.441 11.343 4.323 2.721 2.883 4.082 6.774 4.082 11.674 0 5.021-1.447 9.018-4.338 11.99-2.892 2.973-6.829 4.458-11.81 4.458-4.8 0-8.61-1.41-11.432-4.232-2.822-2.82-4.233-6.673-4.233-11.554m-16.417-7.802c0 1.045.331 1.863.994 2.456.662.592 2.128 1.34 4.398 2.243 2.912 1.166 4.956 2.476 6.131 3.932 1.175 1.456 1.762 3.22 1.762 5.287 0 2.912-1.12 5.252-3.359 7.02-2.24 1.767-5.267 2.65-9.083 2.65-1.285 0-2.706-.155-4.263-.467-1.556-.31-2.877-.707-3.96-1.19v-7.169a17.945 17.945 0 004.277 2.198c1.526.543 2.911.814 4.157.814 1.647 0 2.862-.23 3.645-.693.784-.46 1.175-1.235 1.175-2.319 0-1.005-.406-1.853-1.22-2.546-.813-.693-2.355-1.492-4.624-2.395-2.69-1.125-4.599-2.39-5.724-3.796-1.125-1.406-1.687-3.193-1.687-5.362 0-2.792 1.11-5.086 3.33-6.884 2.217-1.797 5.095-2.696 8.63-2.696 1.084 0 2.3.12 3.645.361 1.346.242 2.47.553 3.374.934v6.93c-.964-.644-2.089-1.195-3.374-1.658-1.286-.462-2.56-.693-3.826-.693-1.386 0-2.465.271-3.238.813-.774.543-1.16 1.286-1.16 2.23m-35.066 7.562c0 3.233.733 5.703 2.2 7.411 1.465 1.707 3.564 2.56 6.295 2.56 2.652 0 4.67-.853 6.055-2.56 1.386-1.708 2.08-4.238 2.08-7.592 0-3.334-.719-5.849-2.155-7.547-1.436-1.697-3.449-2.545-6.039-2.545-2.672 0-4.745.888-6.222 2.666-1.476 1.777-2.214 4.313-2.214 7.607m-7.592.24c0-5.12 1.446-9.177 4.338-12.17 2.893-2.993 6.91-4.489 12.051-4.489 4.84 0 8.621 1.441 11.342 4.323 2.721 2.883 4.082 6.774 4.082 11.674 0 5.021-1.446 9.018-4.338 11.99-2.892 2.973-6.828 4.458-11.809 4.458-4.8 0-8.61-1.41-11.433-4.232-2.822-2.82-4.233-6.673-4.233-11.554m-3.136-16.448c.582 0 1.105.041 1.567.121.462.08.853.18 1.175.301v7.38c-.382-.28-.939-.546-1.672-.798-.733-.25-1.622-.376-2.666-.376-1.788 0-3.299.753-4.534 2.26-1.235 1.505-1.853 3.825-1.853 6.958v15.635h-7.29V98.624h7.29v4.88h.12c.663-1.687 1.667-3.007 3.013-3.96 1.346-.954 2.962-1.432 4.85-1.432m-27.956 26.18c1.084 0 2.28-.25 3.585-.754a15.06 15.06 0 003.615-1.988v6.778c-1.165.663-2.485 1.165-3.962 1.506-1.475.342-3.098.512-4.865.512-4.559 0-8.265-1.44-11.116-4.323-2.852-2.88-4.278-6.562-4.278-11.04 0-4.98 1.456-9.083 4.37-12.307 2.91-3.224 7.037-4.835 12.38-4.835 1.366 0 2.746.176 4.143.527 1.395.352 2.504.758 3.328 1.22v6.99c-1.125-.824-2.274-1.462-3.45-1.914a9.966 9.966 0 00-3.599-.678c-2.872 0-5.192.934-6.959 2.802-1.768 1.868-2.652 4.388-2.652 7.562 0 3.132.85 5.573 2.546 7.32 1.697 1.748 4.002 2.621 6.914 2.621m-22.112 5.302h-7.29V98.624h7.29zm-8.044-39.916c0-1.205.437-2.214 1.311-3.028.874-.813 1.913-1.22 3.118-1.22 1.285 0 2.35.417 3.193 1.25.844.834 1.266 1.833 1.266 2.998 0 1.185-.432 2.18-1.296 2.982-.864.804-1.918 1.205-3.163 1.205-1.246 0-2.295-.406-3.148-1.219-.854-.815-1.28-1.803-1.28-2.968m-6.274-3.284v43.2h-7.5v-33.86h-.12l-13.408 33.86h-4.97l-13.738-33.86h-.09v33.86h-6.929v-43.2h10.755l12.412 32.024h.18l13.105-32.024z"></path>
							<path d="M106.214 106.214H71.996V71.996h34.218z" fill="#f25022"></path>
							<path d="M143.993 106.214h-34.218V71.996h34.218z" fill="#7fba00"></path>
							<path d="M106.214 143.993H71.996v-34.218h34.218z" fill="#00a4ef"></path>
							<path d="M143.993 143.993h-34.218v-34.218h34.218z" fill="#ffb900"></path>
						</g>
					</g>
				</svg>
			</div>
		</a>
	</div> 
				
		<div class="nav-bar-item is-hidden-tablet">
			<div class="nav-bar-menu">
				<button class="nav-bar-button is-title" title="全球导航" aria-expanded="false">
					<span class="nav-bar-menu-title"><!---->文档<!----></span>
					<div class="nav-bar-burger">
						<span></span>
						<span></span>
						<span></span>
						<span class="nav-bar-burger-label"><!---->全球导航<!----></span>
					</div>
				</button>
			</div>
		</div>
	
				
		<nav class="nav-bar-nav" role="navigation" aria-label="全球">
			<ul class="nav-bar-nav-list">
				
		<li class="nav-bar-item is-category">
			<a class="nav-bar-button is-title has-hover-underline" itemprop="url" href="https://docs.microsoft.com/zh-cn/">
				<span><!---->Docs<!----></span>
			</a>
		</li>
	
				<!----> <li class="nav-bar-item">
				<a class=" nav-bar-button has-hover-underline is-active" href="https://docs.microsoft.com/zh-cn/documentation">
					<span><!---->文档<!----></span>
				</a>
		  </li><!----> <li class="nav-bar-item">
				<a class=" nav-bar-button has-hover-underline " href="https://docs.microsoft.com/zh-cn/learn/">
					<span><!---->Learn<!----></span>
				</a>
		  </li><!----> <li class="nav-bar-item">
				<a class=" nav-bar-button has-hover-underline " href="https://docs.microsoft.com/zh-cn/answers/products/">
					<span><!---->Q&amp;A<!----></span>
				</a>
		  </li><!----> <li class="nav-bar-item">
				<a class=" nav-bar-button has-hover-underline " href="https://docs.microsoft.com/zh-cn/samples/browse/">
					<span><!---->代码示例<!----></span>
				</a>
		  </li><!----> <li class="dropdown nav-bar-item" hidden="">
		<button aria-expanded="false" class="dropdown-trigger nav-bar-button  has-hover-underline" aria-controls="ax-96">
			<span><!---->更多<!----></span>
			<span class="nav-bar-button-chevron" aria-hidden="true">
				<span class="docon docon-chevron-down-light expanded-indicator"></span>
			</span>
		</button>
		<ul class="dropdown-menu" id="ax-96" aria-label="更多">
			<!---->
				<li class="nav-bar-item" hidden="">
					<a class=" nav-bar-button is-active" href="https://docs.microsoft.com/zh-cn/documentation"><!---->文档<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item" hidden="">
					<a class=" nav-bar-button " href="https://docs.microsoft.com/zh-cn/learn/"><!---->Learn<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item" hidden="">
					<a class=" nav-bar-button " href="https://docs.microsoft.com/zh-cn/answers/products/"><!---->Q&amp;A<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item" hidden="">
					<a class=" nav-bar-button " href="https://docs.microsoft.com/zh-cn/samples/browse/"><!---->代码示例<!----></a>
				</li>
		  <!---->
		</ul>
	</li><!---->
			</ul>
		</nav>
	
				<span class="nav-bar-spacer"></span>
				
		<div class="nav-bar-search " id="ax-97" hidden="">
			
		<form class="nav-bar-search-form" method="GET" name="nav-bar-search-form" role="search" id="nav-bar-search-form" aria-label="搜索" aria-expanded="false" action="https://docs.microsoft.com/zh-cn/search/">
			<div class="autocomplete" data-bi-name="autocomplete"><!----> <div class="control ">
				<input role="combobox" maxlength="100" aria-autocomplete="list" autocapitalize="off" autocomplete="off" autocorrect="off" spellcheck="false" id="site-search-input" class="autocomplete-input input   is-small" type="search" name="terms" aria-expanded="false" aria-owns="ax-98-listbox" aria-activedescendant="" aria-label="搜索" placeholder="搜索">

				<span aria-hidden="true" class="icon is-small is-left" hidden="">
					<span class="has-text-primary docon docon-undefined"></span>
				</span>

				<span aria-hidden="true" class="autocomplete-loader loader has-text-primary " hidden=""></span>
			</div>

			<ul class="autocomplete-suggestions is-vertically-scrollable" role="listbox" id="ax-98-listbox" aria-label="site-search-input-suggestions" hidden="">
				
			</ul><!----></div>
			<!-- mobile safari will not dispatch submit event unless there's a submit button that is not display:none -->
			<button type="submit" class="visually-hidden" tabindex="-1" aria-hidden="true"></button>
			<input name="category" hidden="" value="">
			<input name="scope" hidden="" value=".NET">
			
			
		</form>
	
		</div>
		
					<div class="nav-bar-search">
						<!-- hidden when the width drops to tablet -->
						
		<form class="nav-bar-search-form" method="GET" name="nav-bar-search-form" role="search" id="nav-bar-search-form-desktop" aria-label="搜索" aria-expanded="false" action="https://docs.microsoft.com/zh-cn/search/">
			<div class="autocomplete" data-bi-name="autocomplete"><!----> <div class="control has-icons-left">
				<input role="combobox" maxlength="100" aria-autocomplete="list" autocapitalize="off" autocomplete="off" autocorrect="off" spellcheck="false" id="ax-99" class="autocomplete-input input control has-icons-left  is-small" type="search" name="terms" aria-expanded="false" aria-owns="ax-100-listbox" aria-activedescendant="" aria-label="搜索" placeholder="搜索">

				<span aria-hidden="true" class="icon is-small is-left">
					<span class="has-text-primary docon docon-search"></span>
				</span>

				<span aria-hidden="true" class="autocomplete-loader loader has-text-primary " hidden=""></span>
			</div>

			<ul class="autocomplete-suggestions is-vertically-scrollable" role="listbox" id="ax-100-listbox" aria-label="ax-99-suggestions" hidden="">
				
			</ul><!----></div>
			<!-- mobile safari will not dispatch submit event unless there's a submit button that is not display:none -->
			<button type="submit" class="visually-hidden" tabindex="-1" aria-hidden="true"></button>
			<input name="category" hidden="" value="">
			<input name="scope" hidden="" value=".NET">
			
			
		</form>
	
					</div>
			  
		<div class="nav-bar-search " hidden="">
			<div class="nav-bar-search-form-expander">
				<button id="form-expander" class="nav-bar-button has-hover-underline " title="搜索" aria-expanded="false" aria-controls="ax-97">
					
		<span class="is-visually-hidden-mobile"><!---->搜索<!----></span>
		<span class="icon" aria-hidden="true">
			<span class="docon docon-search"></span>
		</span>
	
				</button>
			</div>
		</div>
	
				
		<div class="nav-bar-profile">
			
		<a class="docs-sign-in auth-status-determined not-authenticated" href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#"> 登录 </a>
	 
		<div class="dropdown has-caret auth-status-determined authenticated">
			<button class="dropdown-trigger button-reset" aria-controls="user-menu" aria-expanded="false" aria-label="你的帐户">
				<figure class="image is-36x36">
					<img class="has-body-background-medium is-rounded" alt="" data-profile-property="avatarUrl">
				</figure>
			</button>
			<div class="dropdown-menu box has-flex-justify-content-start has-body-background" id="user-menu" role="menu">
				<div class="media is-user-dir">
					<div class="media-left">
						<figure class="image is-48x48" aria-hidden="true">
							<img class="has-body-background-medium is-rounded" aria-labelledby="displayName" data-profile-property="avatarUrl">
						</figure>
					</div>
					<div class="media-content">
						<p class="title is-size-large">
							<span id="displayName" class="is-inline-truncated has-max-width-200" data-profile-property="displayName"></span>
						</p>
						<p class="subtitle is-size-small has-margin-bottom-none">
							<span class="is-inline-truncated has-max-width-200" data-profile-property="upn"></span>
						</p>
					</div>
				</div>
				<ul class="has-padding-top-small has-padding-bottom-medium">
					<li class="has-padding-top-extra-small has-padding-bottom-extra-small">
						<a href="https://docs.microsoft.com/profile" data-profile-property="profileUrl"><!---->配置文件<!----></a>
					</li>
					<li class="has-padding-top-extra-small has-padding-bottom-extra-small">
						<a href="https://docs.microsoft.com/profile" data-profile-property="bookmarksUrl"><!---->书签<!----></a>
					</li>
					<li class="has-padding-top-extra-small has-padding-bottom-extra-small">
						<a href="https://docs.microsoft.com/profile" data-profile-property="collectionsUrl"><!---->集合<!----></a>
					</li>
					<li class="has-padding-top-extra-small">
						<a href="https://docs.microsoft.com/profile" data-profile-property="challengesUrl"><!---->挑战<!----></a>
					</li>
				</ul>
				<div class="has-border-top has-padding-top-medium">
					<a class="docs-sign-out" href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#"><!---->注销<!----></a>
				</div>
			</div>
		</div>
	
		</div>
	
			 <!----></div> <div class="nav-bar has-border-top is-hidden-mobile"><!----> 
		<a class="nav-bar-button is-title has-hover-underline" itemprop="url" href="https://docs.microsoft.com/dotnet/">
			<span>
				.NET
				
			</span>
		</a>
	 
		
		<nav class="nav-bar-nav" role="navigation" aria-label="站点">
			<ul class="nav-bar-nav-list">
				
				<!----> <li class="dropdown nav-bar-item">
		<button aria-expanded="false" class="dropdown-trigger nav-bar-button  has-hover-underline" aria-controls="ax-101">
			<span><!---->语言<!----></span>
			<span class="nav-bar-button-chevron" aria-hidden="true">
				<span class="docon docon-chevron-down-light expanded-indicator"></span>
			</span>
		</button>
		<ul class="dropdown-menu" id="ax-101" aria-label="语言">
			<!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/dotnet/csharp/"><!---->C#<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/dotnet/fsharp/"><!---->F#<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/dotnet/visual-basic/"><!---->Visual Basic<!----></a>
				</li>
		  <!---->
		</ul>
	</li><!----> <li class="dropdown nav-bar-item">
		<button aria-expanded="false" class="dropdown-trigger nav-bar-button  has-hover-underline" aria-controls="ax-102">
			<span><!---->工作负载<!----></span>
			<span class="nav-bar-button-chevron" aria-hidden="true">
				<span class="docon docon-chevron-down-light expanded-indicator"></span>
			</span>
		</button>
		<ul class="dropdown-menu" id="ax-102" aria-label="工作负载">
			<!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/aspnet/core/"><!---->Web<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/xamarin/"><!---->移动<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/dotnet/azure/"><!---->云<!----></a>
				</li>
		  <!----> <li class="dropdown nav-bar-item">
		<button aria-expanded="false" class="dropdown-trigger nav-bar-button  " aria-controls="ax-103">
			<span><!---->桌面<!----></span>
			<span class="nav-bar-button-chevron" aria-hidden="true">
				<span class="docon docon-chevron-right-light "></span>
			</span>
		</button>
		<ul class="dropdown-menu" id="ax-103" aria-label="桌面">
			<!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/dotnet/desktop-wpf/"><!---->Windows Presentation Foundation<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/dotnet/framework/winforms/"><!---->Windows 窗体<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/windows/uwp/"><!---->通用 Windows 应用<!----></a>
				</li>
		  <!---->
		</ul>
	</li><!----> <li class="dropdown nav-bar-item">
		<button aria-expanded="false" class="dropdown-trigger nav-bar-button  " aria-controls="ax-104">
			<span><!---->机器学习和数据<!----></span>
			<span class="nav-bar-button-chevron" aria-hidden="true">
				<span class="docon docon-chevron-right-light "></span>
			</span>
		</button>
		<ul class="dropdown-menu" id="ax-104" aria-label="机器学习和数据">
			<!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/dotnet/machine-learning/"><!---->ML.NET<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/dotnet/spark/"><!---->.NET for Apache Spark<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/ef/"><!---->实体框架<!----></a>
				</li>
		  <!---->
		</ul>
	</li><!---->
		</ul>
	</li><!----> <li class="dropdown nav-bar-item">
		<button aria-expanded="false" class="dropdown-trigger nav-bar-button  has-hover-underline" aria-controls="ax-105">
			<span><!---->API<!----></span>
			<span class="nav-bar-button-chevron" aria-hidden="true">
				<span class="docon docon-chevron-down-light expanded-indicator"></span>
			</span>
		</button>
		<ul class="dropdown-menu" id="ax-105" aria-label="API">
			<!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/dotnet/api/?view=netcore-3.1"><!---->.NET Core<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/dotnet/api/?view=netframework-4.8"><!---->.NET Framework<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/dotnet/api/?view=aspnetcore-3.1"><!---->ASP.NET<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/dotnet/api/?view=ml-dotnet"><!---->ML.NET<!----></a>
				</li>
		  <!---->
		</ul>
	</li><!----> <li class="dropdown nav-bar-item">
		<button aria-expanded="false" class="dropdown-trigger nav-bar-button  has-hover-underline" aria-controls="ax-106">
			<span><!---->资源<!----></span>
			<span class="nav-bar-button-chevron" aria-hidden="true">
				<span class="docon docon-chevron-down-light expanded-indicator"></span>
			</span>
		</button>
		<ul class="dropdown-menu" id="ax-106" aria-label="资源">
			<!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://dotnet.microsoft.com/learn/dotnet/what-is-dotnet"><!---->什么是 .NET？<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://dotnet.microsoft.com/learn/dotnet/architecture-guides"><!---->.NET 体系结构指南<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://dotnet.microsoft.com/learn"><!---->学习材料<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://dotnet.microsoft.com/download"><!---->下载<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://dotnet.microsoft.com/platform/community"><!---->社区<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://dotnet.microsoft.com/platform/support"><!---->支持<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://devblogs.microsoft.com/dotnet/"><!---->博客<!----></a>
				</li>
		  <!---->
		</ul>
	</li><!----> <li class="dropdown nav-bar-item" hidden="">
		<button aria-expanded="false" class="dropdown-trigger nav-bar-button  has-hover-underline" aria-controls="ax-107">
			<span><!---->更多<!----></span>
			<span class="nav-bar-button-chevron" aria-hidden="true">
				<span class="docon docon-chevron-down-light expanded-indicator"></span>
			</span>
		</button>
		<ul class="dropdown-menu" id="ax-107" aria-label="更多">
			<!----> <li class="dropdown nav-bar-item" hidden="">
		<button aria-expanded="false" class="dropdown-trigger nav-bar-button  " aria-controls="ax-108">
			<span><!---->语言<!----></span>
			<span class="nav-bar-button-chevron" aria-hidden="true">
				<span class="docon docon-chevron-right-light "></span>
			</span>
		</button>
		<ul class="dropdown-menu" id="ax-108" aria-label="语言">
			<!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/dotnet/csharp/"><!---->C#<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/dotnet/fsharp/"><!---->F#<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/dotnet/visual-basic/"><!---->Visual Basic<!----></a>
				</li>
		  <!---->
		</ul>
	</li><!----> <li class="dropdown nav-bar-item" hidden="">
		<button aria-expanded="false" class="dropdown-trigger nav-bar-button  " aria-controls="ax-109">
			<span><!---->工作负载<!----></span>
			<span class="nav-bar-button-chevron" aria-hidden="true">
				<span class="docon docon-chevron-right-light "></span>
			</span>
		</button>
		<ul class="dropdown-menu" id="ax-109" aria-label="工作负载">
			<!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/aspnet/core/"><!---->Web<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/xamarin/"><!---->移动<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/dotnet/azure/"><!---->云<!----></a>
				</li>
		  <!----> <li class="dropdown nav-bar-item">
		<button aria-expanded="false" class="dropdown-trigger nav-bar-button  " aria-controls="ax-110">
			<span><!---->桌面<!----></span>
			<span class="nav-bar-button-chevron" aria-hidden="true">
				<span class="docon docon-chevron-right-light "></span>
			</span>
		</button>
		<ul class="dropdown-menu" id="ax-110" aria-label="桌面">
			<!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/dotnet/desktop-wpf/"><!---->Windows Presentation Foundation<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/dotnet/framework/winforms/"><!---->Windows 窗体<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/windows/uwp/"><!---->通用 Windows 应用<!----></a>
				</li>
		  <!---->
		</ul>
	</li><!----> <li class="dropdown nav-bar-item">
		<button aria-expanded="false" class="dropdown-trigger nav-bar-button  " aria-controls="ax-111">
			<span><!---->机器学习和数据<!----></span>
			<span class="nav-bar-button-chevron" aria-hidden="true">
				<span class="docon docon-chevron-right-light "></span>
			</span>
		</button>
		<ul class="dropdown-menu" id="ax-111" aria-label="机器学习和数据">
			<!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/dotnet/machine-learning/"><!---->ML.NET<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/dotnet/spark/"><!---->.NET for Apache Spark<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/ef/"><!---->实体框架<!----></a>
				</li>
		  <!---->
		</ul>
	</li><!---->
		</ul>
	</li><!----> <li class="dropdown nav-bar-item" hidden="">
		<button aria-expanded="false" class="dropdown-trigger nav-bar-button  " aria-controls="ax-112">
			<span><!---->API<!----></span>
			<span class="nav-bar-button-chevron" aria-hidden="true">
				<span class="docon docon-chevron-right-light "></span>
			</span>
		</button>
		<ul class="dropdown-menu" id="ax-112" aria-label="API">
			<!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/dotnet/api/?view=netcore-3.1"><!---->.NET Core<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/dotnet/api/?view=netframework-4.8"><!---->.NET Framework<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/dotnet/api/?view=aspnetcore-3.1"><!---->ASP.NET<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://docs.microsoft.com/zh-cn/dotnet/api/?view=ml-dotnet"><!---->ML.NET<!----></a>
				</li>
		  <!---->
		</ul>
	</li><!----> <li class="dropdown nav-bar-item" hidden="">
		<button aria-expanded="false" class="dropdown-trigger nav-bar-button  " aria-controls="ax-113">
			<span><!---->资源<!----></span>
			<span class="nav-bar-button-chevron" aria-hidden="true">
				<span class="docon docon-chevron-right-light "></span>
			</span>
		</button>
		<ul class="dropdown-menu" id="ax-113" aria-label="资源">
			<!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://dotnet.microsoft.com/learn/dotnet/what-is-dotnet"><!---->什么是 .NET？<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://dotnet.microsoft.com/learn/dotnet/architecture-guides"><!---->.NET 体系结构指南<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://dotnet.microsoft.com/learn"><!---->学习材料<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://dotnet.microsoft.com/download"><!---->下载<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://dotnet.microsoft.com/platform/community"><!---->社区<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://dotnet.microsoft.com/platform/support"><!---->支持<!----></a>
				</li>
		  <!---->
				<li class="nav-bar-item">
					<a class="has-external-link-indicator nav-bar-button " href="https://devblogs.microsoft.com/dotnet/"><!---->博客<!----></a>
				</li>
		  <!---->
		</ul>
	</li><!---->
		</ul>
	</li><!---->
			</ul>
		</nav>
	
		<span class="nav-bar-spacer"></span>
		
		<ol class="nav-bar-list">
			 
		<li class="nav-bar-item ">
			<a class="button is-small is-primary " href="https://dotnet.microsoft.com/download">
				下载 .NET
			</a>
		</li>
	
		</ol>
	 
	 <!----></div> <!----></header>		</div>

						<div class="content-header uhf-container has-padding has-default-focus has-border-bottom-none" data-bi-name="content-header">
					<nav class="breadcrumb-holder has-padding-none has-padding-left-medium-tablet has-padding-right-medium-tablet has-padding-left-none-uhf-tablet has-padding-left-none-uhf-tablet has-padding-none-desktop has-flex-grow" data-bi-name="breadcrumb" itemscope="" itemtype="http://schema.org/BreadcrumbList" role="navigation" aria-label="痕迹">
						<ul id="page-breadcrumbs" class="breadcrumbs"><!----><!---->
			<li itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem">
				
							<a itemprop="item" href="https://docs.microsoft.com/zh-cn/">
								<span itemprop="name"><!---->Docs<!----></span>
							</a>
					  
				<meta itemprop="position" content="1">
			</li>
		<!---->
			<li itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem">
				
							<a itemprop="item" href="https://docs.microsoft.com/zh-cn/dotnet/">
								<span itemprop="name"><!---->.NET<!----></span>
							</a>
					  
				<meta itemprop="position" content="2">
			</li>
		<!---->
			<li itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem">
				
							<a itemprop="item" href="https://docs.microsoft.com/zh-cn/dotnet/fundamentals/">
								<span itemprop="name"><!---->.NET 基础知识<!----></span>
							</a>
					  
				<meta itemprop="position" content="3">
			</li>
		<!----><!----></ul>
					</nav>
				<div class="content-header-controls">
					<button type="button" class="contents-button button" data-bi-name="contents-expand" aria-haspopup="true">
						<span class="icon"><span class="docon docon-menu" aria-hidden="true"></span></span>
						<span class="contents-expand-title">目录</span>
					</button>
					<button type="button" class="ap-collapse-behavior ap-expanded button" data-bi-name="ap-collapse" aria-controls="action-panel">
						<span class="icon"><span class="docon docon-exit-mode" aria-hidden="true"></span></span>
						<span>退出焦点模式</span>
					</button>
				</div>
				<div class="has-padding-none-tablet has-padding-medium is-size-small is-flex-touch has-flex-justify-content-space-between-touch has-flex-grow page-action-holder">
					<ul class="is-hidden-mobile action-list has-flex-justify-content-start has-flex-justify-content-end-tablet is-flex is-flex-row has-flex-wrap has-flex-grow is-unstyled">
						<li>
							<button type="button" class="bookmark button is-text has-inner-focus is-small is-icon-only-touch" data-list-type="bookmarks" data-bi-name="bookmark" title="添加 使用插件创建 .NET Core 应用程序 - .NET | Microsoft Docs 的书签" aria-pressed="false">
								<span class="icon" aria-hidden="true">
									<span class="docon docon-single-bookmark"></span>
								</span>
								<span class="bookmark-status is-visually-hidden-touch is-hidden-portrait">书签</span>
							</button>
						</li>
							<li id="feedback-section-link">
								<a href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#feedback" class="button is-text has-inner-focus is-small is-icon-only-touch" data-bi-name="comments" title="发送有关此页面的反馈">
									<span class="icon" aria-hidden="true">
										<span class="docon docon-comment-lines"></span>
									</span>
									<span class="is-visually-hidden-touch is-hidden-portrait">反馈</span>
								</a>
							</li>
								<li id="contenteditbtn">
									<a href="https://github.com/dotnet/docs.zh-cn/blob/live/docs/core/tutorials/creating-app-with-plugin-support.md" class="button is-text has-inner-focus is-icon-only-touch is-small" title="编辑本文" data-bi-name="edit" data-original_content_git_url="https://github.com/dotnet/docs.zh-cn/blob/live-sxs/docs/core/tutorials/creating-app-with-plugin-support.md" data-original_content_git_url_template="{repo}/blob/{branch}/docs/core/tutorials/creating-app-with-plugin-support.md" data-pr_repo="" data-pr_branch="">
									<span class="icon" aria-hidden="true">
										<span class="docon docon-edit-outline"></span>
									</span>
									<span class="is-visually-hidden-touch is-hidden-portrait">编辑</span>
								</a>
							</li>
						<li>
<div class="sharing dropdown has-caret">
	<button class="dropdown-trigger button is-text is-fullwidth has-flex-justify-content-start has-inner-focus is-small is-icon-only-touch" aria-controls="sharing-menu" aria-expanded="false" title="共享本文" data-bi-name="share">
		<span class="icon" aria-hidden="true">
			<span class="docon docon-sharing"></span>
		</span>
		<span class="is-visually-hidden-touch is-hidden-portrait">共享</span>
	</button>
	<div class="dropdown-menu has-padding-small" id="sharing-menu">
		<ul data-bi-name="share-links">
			<li>
				<a class="button is-text is-fullwidth has-flex-justify-content-start has-inner-focus is-small share-twitter" data-bi-name="twitter" href="https://twitter.com/intent/tweet?original_referer=https%3A%2F%2Fdocs.microsoft.com%2Fzh-cn%2Fdotnet%2Fcore%2Ftutorials%2Fcreating-app-with-plugin-support%3FWT.mc_id%3Dtwitter&amp;text=%E4%BD%BF%E7%94%A8%E6%8F%92%E4%BB%B6%E5%88%9B%E5%BB%BA%20.NET%20Core%20%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%20-%20.NET%20%7C%20Microsoft%20Docs&amp;tw_p=tweetbutton&amp;url=https%3A%2F%2Fdocs.microsoft.com%2Fzh-cn%2Fdotnet%2Fcore%2Ftutorials%2Fcreating-app-with-plugin-support%3FWT.mc_id%3Dtwitter">
					<span class="icon">
						<span class="docon docon-brand-twitter has-text-primary" aria-hidden="true"></span>
					</span>
					<span>Twitter</span>
				</a>
			</li>
			<li>
				<a class="button is-text is-fullwidth has-flex-justify-content-start has-inner-focus is-small share-linkedin" data-bi-name="linkedin" href="https://www.linkedin.com/cws/share?url=https%3A%2F%2Fdocs.microsoft.com%2Fzh-cn%2Fdotnet%2Fcore%2Ftutorials%2Fcreating-app-with-plugin-support%3FWT.mc_id%3Dlinkedin">
					<span class="icon">
						<span class="docon docon-brand-linkedin has-text-primary" aria-hidden="true"></span>
					</span>
					<span>LinkedIn</span>
				</a>
			</li>
			<li>
				<a class="button is-text is-fullwidth has-flex-justify-content-start has-inner-focus is-small share-facebook" data-bi-name="facebook" href="https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fdocs.microsoft.com%2Fzh-cn%2Fdotnet%2Fcore%2Ftutorials%2Fcreating-app-with-plugin-support%3FWT.mc_id%3Dfacebook">
					<span class="icon">
						<span class="docon docon-brand-facebook has-text-primary" aria-hidden="true"></span>
					</span>
					<span>Facebook</span>
				</a>
			</li>
			<li>
				<a class="button is-text is-fullwidth has-flex-justify-content-start has-inner-focus is-small share-email" data-bi-name="email" href="mailto:?subject=%5B%E5%85%B1%E4%BA%AB%E6%96%87%E7%AB%A0%5D%20%E4%BD%BF%E7%94%A8%E6%8F%92%E4%BB%B6%E5%88%9B%E5%BB%BA%20.NET%20Core%20%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%20-%20.NET%20%7C%20Microsoft%20Docs&amp;body=%E4%BD%BF%E7%94%A8%E6%8F%92%E4%BB%B6%E5%88%9B%E5%BB%BA%20.NET%20Core%20%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%20-%20.NET%20%7C%20Microsoft%20Docs%0A%0Ahttps%3A%2F%2Fdocs.microsoft.com%2Fzh-cn%2Fdotnet%2Fcore%2Ftutorials%2Fcreating-app-with-plugin-support%3FWT.mc_id%3Demail">
					<span class="icon">
						<span class="docon docon-mail-message-fill has-text-primary" aria-hidden="true"></span>
					</span>
					<span>电子邮件</span>
				</a>
			</li>
			<li>
				<span class="button is-text is-fullwidth has-flex-justify-content-start has-inner-focus is-small share-wechat has-padding-top-extra-small has-padding-left-medium has-padding-right-medium">
					<span class="icon">
						<span class="docon docon-wechat has-text-primary" data-bi-name="wechat" aria-hidden="true"></span>
					</span>
					<span>微信</span>
				</span>
			</li>
			<li>
				<canvas class="qr-code" height="96" width="96"></canvas>
			</li>
		</ul>
	</div>
</div>						</li>
						<li>

<div class="lang-toggle-container" style="display: flex;">
	<label for="language-toggle" aria-hidden="true" tabindex="-1">使用英语阅读</label>
	<div class="checkbox-toggle-wrapper">
		<input type="checkbox" id="language-toggle" aria-label="使用英语阅读" data-m="{&quot;cN&quot;:&quot;language-toggle&quot;,&quot;value&quot;:&quot;off&quot;}">
		<label for="language-toggle" class="switch"></label>
	</div>
</div>						</li>
					</ul>
					<button type="button" class="has-border contents-button button is-small is-text is-hidden-tablet has-inner-focus" aria-label="目录" data-bi-name="contents-expand">
						<span class="icon">
							<span class="docon docon-editor-list-bullet" aria-hidden="true"></span>
						</span>
						<span class="contents-expand-title">目录</span>
					</button>
					<div class="is-invisible"></div>
					<div class="is-hidden-tablet level-item is-flexible level-right">
						<button type="button" class="page-actions-button button is-small is-text is-hidden-tablet has-inner-focus has-border is-full-height  has-margin-left-small" aria-label="页面操作" data-bi-name="pageactions">
							<span class="icon">
								<span class="docon docon-more-vertical" aria-hidden="true"></span>
							</span>
						</button>
					</div>
				</div>
			</div>



		<div id="disclaimer-holder" class="has-overflow-hidden has-default-focus">
			<!-- liquid-tag banners sectional -->
		</div>
	</div>

	<div class="mainContainer  uhf-container has-top-padding  has-default-focus" data-bi-name="body">

		<div class="columns has-large-gaps is-gapless-mobile ">

			<div id="left-container" class="left-container is-hidden-mobile column is-one-third-tablet is-one-quarter-desktop">
				<nav id="affixed-left-container" class="is-fixed is-flex is-flex-column" role="navigation" aria-label="主要" style="width: 320.25px; top: 166px; bottom: 24px;" data-bi-name="left toc"><form action="javascript:" role="search" aria-label="搜索" class="has-margin-bottom-small"><label class="visually-hidden" for="ax-114">搜索</label><div class="autocomplete is-block" data-bi-name="autocomplete"><!----> <div class="control has-icons-left">
				<input role="combobox" maxlength="100" aria-autocomplete="list" autocapitalize="off" autocomplete="off" autocorrect="off" spellcheck="false" id="ax-114" class="autocomplete-input input control has-icons-left is-full-width is-small" type="text" aria-expanded="false" aria-owns="ax-115-listbox" aria-activedescendant="" placeholder="按标题筛选">

				<span aria-hidden="true" class="icon is-small is-left">
					<span class="has-text-primary docon docon-filter-settings"></span>
				</span>

				<span aria-hidden="true" class="autocomplete-loader loader has-text-primary " hidden=""></span>
			</div>

			<ul class="autocomplete-suggestions is-vertically-scrollable" role="listbox" id="ax-115-listbox" aria-label="ax-114-suggestions" hidden="">
				
			</ul><!----></div></form><ul class="tree is-vertically-scrollable has-flex-grow has-flex-shrink" role="tree" aria-label="目录" data-bi-name="tree" data-is-collapsible="true"><li role="none"><a aria-setsize="15" aria-level="1" aria-posinset="1" role="treeitem" tabindex="-1" class="tree-item is-leaf has-external-link-indicator" data-bi-name="tree-leaf" href="https://docs.microsoft.com/zh-cn/dotnet/fundamentals/">.NET 文档</a></li><li class="tree-item" aria-setsize="15" aria-level="1" aria-posinset="2" role="treeitem" tabindex="-1" id="title-2-1" aria-expanded="false"><span data-bi-name="tree-expander" class="tree-expander"><span class="tree-expander-indicator docon docon-chevron-right-light" aria-hidden="true"></span>入门</span></li><li class="tree-item" aria-setsize="15" aria-level="1" aria-posinset="3" role="treeitem" tabindex="-1" id="title-3-1" aria-expanded="false"><span data-bi-name="tree-expander" class="tree-expander"><span class="tree-expander-indicator docon docon-chevron-right-light" aria-hidden="true"></span>概述</span></li><li class="tree-item" aria-setsize="15" aria-level="1" aria-posinset="4" role="treeitem" tabindex="-1" id="title-4-1" aria-expanded="false"><span data-bi-name="tree-expander" class="tree-expander"><span class="tree-expander-indicator docon docon-chevron-right-light" aria-hidden="true"></span>.NET 中的新增功能</span></li><li class="tree-item" aria-setsize="15" aria-level="1" aria-posinset="5" role="treeitem" tabindex="-1" id="title-5-1" aria-expanded="false"><span data-bi-name="tree-expander" class="tree-expander"><span class="tree-expander-indicator docon docon-chevron-right-light" aria-hidden="true"></span>工具和诊断</span></li><li class="tree-item is-expanded" aria-setsize="15" aria-level="1" aria-posinset="6" role="treeitem" tabindex="-1" id="title-6-1" aria-expanded="true"><span data-bi-name="tree-expander" class="tree-expander"><span class="tree-expander-indicator docon docon-chevron-right-light" aria-hidden="true"></span>执行模型</span><ul class="tree-group" role="group"><li role="none"><a aria-setsize="7" aria-level="2" aria-posinset="1" role="treeitem" tabindex="-1" class="tree-item is-leaf has-external-link-indicator" data-bi-name="tree-leaf" href="https://docs.microsoft.com/zh-cn/dotnet/standard/clr">公共语言运行时 (CLR)</a></li><li role="none"><a aria-setsize="7" aria-level="2" aria-posinset="2" role="treeitem" tabindex="-1" class="tree-item is-leaf has-external-link-indicator" data-bi-name="tree-leaf" href="https://docs.microsoft.com/zh-cn/dotnet/standard/managed-execution-process">托管执行过程</a></li><li role="none"><a aria-setsize="7" aria-level="2" aria-posinset="3" role="treeitem" tabindex="-1" class="tree-item is-leaf has-external-link-indicator" data-bi-name="tree-leaf" href="https://docs.microsoft.com/zh-cn/dotnet/standard/assembly/">.NET 中的程序集</a></li><li role="none"><a aria-setsize="7" aria-level="2" aria-posinset="4" role="treeitem" tabindex="-1" class="tree-item is-leaf has-external-link-indicator" data-bi-name="tree-leaf" href="https://docs.microsoft.com/zh-cn/dotnet/standard/metadata-and-self-describing-components">元数据和自描述组件</a></li><li class="tree-item is-expanded" aria-setsize="7" aria-level="2" aria-posinset="5" role="treeitem" tabindex="-1" id="title-6-1_5-2" aria-expanded="true"><span data-bi-name="tree-expander" class="tree-expander"><span class="tree-expander-indicator docon docon-chevron-right-light" aria-hidden="true"></span>依赖项加载</span><ul class="tree-group" role="group"><li role="none"><a aria-setsize="4" aria-level="3" aria-posinset="1" role="treeitem" tabindex="-1" class="tree-item is-leaf has-external-link-indicator" data-bi-name="tree-leaf" href="https://docs.microsoft.com/zh-cn/dotnet/core/dependency-loading/overview">依赖项加载</a></li><li role="none"><a aria-setsize="4" aria-level="3" aria-posinset="2" role="treeitem" tabindex="-1" class="tree-item is-leaf has-external-link-indicator" data-bi-name="tree-leaf" href="https://docs.microsoft.com/zh-cn/dotnet/core/dependency-loading/understanding-assemblyloadcontext">了解 AssemblyLoadContext</a></li><li class="tree-item" aria-setsize="4" aria-level="3" aria-posinset="3" role="treeitem" tabindex="-1" id="title-6-1_5-2_3-3" aria-expanded="false"><span data-bi-name="tree-expander" class="tree-expander"><span class="tree-expander-indicator docon docon-chevron-right-light" aria-hidden="true"></span>依赖项加载详细信息</span></li><li class="tree-item is-expanded" aria-setsize="4" aria-level="3" aria-posinset="4" role="treeitem" tabindex="-1" id="title-6-1_5-2_4-3" aria-expanded="true"><span data-bi-name="tree-expander" class="tree-expander"><span class="tree-expander-indicator docon docon-chevron-right-light" aria-hidden="true"></span>教程</span><ul class="tree-group" role="group"><li role="none"><a aria-setsize="2" aria-level="4" aria-posinset="1" role="treeitem" tabindex="0" class="tree-item is-leaf has-external-link-indicator is-selected" data-bi-name="tree-leaf" href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support" aria-current="page">使用插件创建 .NET 应用程序</a></li><li role="none"><a aria-setsize="2" aria-level="4" aria-posinset="2" role="treeitem" tabindex="-1" class="tree-item is-leaf has-external-link-indicator" data-bi-name="tree-leaf" href="https://docs.microsoft.com/zh-cn/dotnet/standard/assembly/unloadability">如何在 .NET 中使用和调试程序集可卸载性</a></li></ul></li></ul></li><li class="tree-item" aria-setsize="7" aria-level="2" aria-posinset="6" role="treeitem" tabindex="-1" id="title-6-1_6-2" aria-expanded="false"><span data-bi-name="tree-expander" class="tree-expander"><span class="tree-expander-indicator docon docon-chevron-right-light" aria-hidden="true"></span>版本控制</span></li><li class="tree-item" aria-setsize="7" aria-level="2" aria-posinset="7" role="treeitem" tabindex="-1" id="title-6-1_7-2" aria-expanded="false"><span data-bi-name="tree-expander" class="tree-expander"><span class="tree-expander-indicator docon docon-chevron-right-light" aria-hidden="true"></span>运行时配置</span></li></ul></li><li class="tree-item" aria-setsize="15" aria-level="1" aria-posinset="7" role="treeitem" tabindex="-1" id="title-7-1" aria-expanded="false"><span data-bi-name="tree-expander" class="tree-expander"><span class="tree-expander-indicator docon docon-chevron-right-light" aria-hidden="true"></span>部署模型</span></li><li class="tree-item" aria-setsize="15" aria-level="1" aria-posinset="8" role="treeitem" tabindex="-1" id="title-8-1" aria-expanded="false"><span data-bi-name="tree-expander" class="tree-expander"><span class="tree-expander-indicator docon docon-chevron-right-light" aria-hidden="true"></span>基本编码组件</span></li><li class="tree-item" aria-setsize="15" aria-level="1" aria-posinset="9" role="treeitem" tabindex="-1" id="title-9-1" aria-expanded="false"><span data-bi-name="tree-expander" class="tree-expander"><span class="tree-expander-indicator docon docon-chevron-right-light" aria-hidden="true"></span>运行时库</span></li><li class="tree-item" aria-setsize="15" aria-level="1" aria-posinset="10" role="treeitem" tabindex="-1" id="title-10-1" aria-expanded="false"><span data-bi-name="tree-expander" class="tree-expander"><span class="tree-expander-indicator docon docon-chevron-right-light" aria-hidden="true"></span>数据访问</span></li><li class="tree-item" aria-setsize="15" aria-level="1" aria-posinset="11" role="treeitem" tabindex="-1" id="title-11-1" aria-expanded="false"><span data-bi-name="tree-expander" class="tree-expander"><span class="tree-expander-indicator docon docon-chevron-right-light" aria-hidden="true"></span>并行处理、并发和异步</span></li><li class="tree-item" aria-setsize="15" aria-level="1" aria-posinset="12" role="treeitem" tabindex="-1" id="title-12-1" aria-expanded="false"><span data-bi-name="tree-expander" class="tree-expander"><span class="tree-expander-indicator docon docon-chevron-right-light" aria-hidden="true"></span>正在测试</span></li><li role="none"><a aria-setsize="15" aria-level="1" aria-posinset="13" role="treeitem" tabindex="-1" class="tree-item is-leaf has-external-link-indicator" data-bi-name="tree-leaf" href="https://docs.microsoft.com/zh-cn/dotnet/standard/security/">安全性</a></li><li class="tree-item" aria-setsize="15" aria-level="1" aria-posinset="14" role="treeitem" tabindex="-1" id="title-14-1" aria-expanded="false"><span data-bi-name="tree-expander" class="tree-expander"><span class="tree-expander-indicator docon docon-chevron-right-light" aria-hidden="true"></span>高级主题</span></li><li class="tree-item" aria-setsize="15" aria-level="1" aria-posinset="15" role="treeitem" tabindex="-1" id="title-15-1" aria-expanded="false"><span data-bi-name="tree-expander" class="tree-expander"><span class="tree-expander-indicator docon docon-chevron-right-light" aria-hidden="true"></span>迁移指南</span></li></ul><a class="button is-small is-text has-flex-justify-content-start has-inner-focus has-margin-top-small has-border-top has-border-bottom has-flex-shrink-none" href="https://docs.microsoft.com/zh-cn/dotnet/opbuildpdf/fundamentals/toc.pdf?branch=live" data-bi-name="downloadPdf" rel="nofollow"><!----> <span class="icon is-size-extra-small has-text-subtle">
				<span aria-hidden="true" class="docon docon-dictionary-download"></span>
			</span>
			<span><!---->下载 PDF<!----></span><!----></a></nav>
			</div>

			<section class="primary-holder column is-two-thirds-tablet is-three-quarters-desktop">
				<div class="columns is-gapless-mobile has-large-gaps ">


				<div id="main-column" class="column  is-full is-four-fifths-desktop ">

					<main id="main" role="main" class="content " data-bi-name="content" lang="zh-cn" dir="ltr">



						<h1 id="create-a-net-core-application-with-plugins"><span data-ttu-id="3bd58-103">使用插件创建 .NET Core 应用程序</span><span class="sxs-lookup"><span data-stu-id="3bd58-103">Create a .NET Core application with plugins</span></span></h1>

						<ul class="metadata page-metadata" data-bi-name="page info" lang="zh-cn" dir="ltr">
							<li>
								<time class="" data-article-date="" aria-label="文章评审日期" datetime="2019-10-16T00:00:00.000Z" data-article-date-source="ms.date">2019/10/16</time>
							</li>
								<li class="contributors-holder">
									<ul class="facepile has-margin-left-none is-small" data-bi-name="contributors">
														<li class="facepile-item">
															<a href="https://github.com/jkoritzinsky" title="jkoritzinsky" aria-label="jkoritzinskyGithub 个人资料" data-src="https://github.com/jkoritzinsky.png?size=32" data-contributor-name="jkoritzinsky" class="facepile-item-coin">
																<img class="facepile-item-coin-image durable-image has-error" aria-hidden="true" src="./使用插件创建 .NET Core 应用程序 - .NET _ Microsoft Docs_files/jkoritzinsky.png" role="presentation" onerror="this.className=&#39;facepile-item-coin-image durable-image has-error&#39;;">
																<span class="facepile-item-coin-text durable-image-fallback facepile-item-teal" aria-hidden="true">j</span>
															</a>
														</li>
														<li class="facepile-item">
															<a href="https://github.com/olprod" title="olprod" aria-label="olprodGithub 个人资料" data-src="https://github.com/olprod.png?size=32" data-contributor-name="olprod" class="facepile-item-coin">
																<img class="facepile-item-coin-image durable-image has-error" aria-hidden="true" src="./使用插件创建 .NET Core 应用程序 - .NET _ Microsoft Docs_files/olprod.png" role="presentation" onerror="this.className=&#39;facepile-item-coin-image durable-image has-error&#39;;">
																<span class="facepile-item-coin-text durable-image-fallback facepile-item-red" aria-hidden="true">o</span>
															</a>
														</li>
									</ul>
								</li>
						</ul>

						<nav id="center-doc-outline" class="doc-outline is-hidden-desktop" data-bi-name="intopic toc" role="navigation" aria-label="文章大纲">
							<h3>本文内容</h3>
						<ol><li><a href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#prerequisites">系统必备</a></li><li><a href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#create-the-application">创建应用程序</a></li><li><a href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#create-the-plugin-interfaces">创建插件接口</a></li><li><a href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#load-plugins">加载插件</a></li><li><a href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#simple-plugin-with-no-dependencies">不具有依赖项的简单插件</a></li><li><a href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#plugin-with-library-dependencies">具有库依赖项的插件</a></li><li><a href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#other-examples-in-the-sample">示例中的其他示例</a></li><li><a href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#reference-a-plugin-interface-from-a-nuget-package">从 NuGet 包引用插件接口</a></li><li><a href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#plugin-target-framework-recommendations">插件目标框架建议</a></li><li><a href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#plugin-framework-references">插件框架引用</a></li></ol></nav>

						<!-- <content> -->
							<p><span data-ttu-id="3bd58-104">本教程展示了如何创建自定义的 <a href="https://docs.microsoft.com/zh-cn/dotnet/api/system.runtime.loader.assemblyloadcontext" data-linktype="absolute-path">AssemblyLoadContext</a> 来加载插件。</span><span class="sxs-lookup"><span data-stu-id="3bd58-104">This tutorial shows you how to create a custom <a href="https://docs.microsoft.com/zh-cn/dotnet/api/system.runtime.loader.assemblyloadcontext" data-linktype="absolute-path">AssemblyLoadContext</a> to load plugins.</span></span> <span data-ttu-id="3bd58-105"><a href="https://docs.microsoft.com/zh-cn/dotnet/api/system.runtime.loader.assemblydependencyresolver" data-linktype="absolute-path">AssemblyDependencyResolver</a> 用于解析插件的依赖项。</span><span class="sxs-lookup"><span data-stu-id="3bd58-105">An <a href="https://docs.microsoft.com/zh-cn/dotnet/api/system.runtime.loader.assemblydependencyresolver" data-linktype="absolute-path">AssemblyDependencyResolver</a> is used to resolve the dependencies of the plugin.</span></span> <span data-ttu-id="3bd58-106">该教程正确地将插件依赖项与主机应用程序隔离开来。</span><span class="sxs-lookup"><span data-stu-id="3bd58-106">The tutorial correctly isolates the plugin's dependencies from the hosting application.</span></span> <span data-ttu-id="3bd58-107">将了解如何执行以下操作：</span><span class="sxs-lookup"><span data-stu-id="3bd58-107">You'll learn how to:</span></span></p>
<ul>
<li><span data-ttu-id="3bd58-108">构建支持插件的项目。</span><span class="sxs-lookup"><span data-stu-id="3bd58-108">Structure a project to support plugins.</span></span></li>
<li><span data-ttu-id="3bd58-109">创建自定义 <a href="https://docs.microsoft.com/zh-cn/dotnet/api/system.runtime.loader.assemblyloadcontext" data-linktype="absolute-path">AssemblyLoadContext</a> 加载每个插件。</span><span class="sxs-lookup"><span data-stu-id="3bd58-109">Create a custom <a href="https://docs.microsoft.com/zh-cn/dotnet/api/system.runtime.loader.assemblyloadcontext" data-linktype="absolute-path">AssemblyLoadContext</a> to load each plugin.</span></span></li>
<li><span data-ttu-id="3bd58-110">使用 <a href="https://docs.microsoft.com/zh-cn/dotnet/api/system.runtime.loader.assemblydependencyresolver" data-linktype="absolute-path">System.Runtime.Loader.AssemblyDependencyResolver</a> 类型允许插件具有依赖项。</span><span class="sxs-lookup"><span data-stu-id="3bd58-110">Use the <a href="https://docs.microsoft.com/zh-cn/dotnet/api/system.runtime.loader.assemblydependencyresolver" data-linktype="absolute-path">System.Runtime.Loader.AssemblyDependencyResolver</a> type to allow plugins to have dependencies.</span></span></li>
<li><span data-ttu-id="3bd58-111">只需复制生成项目就可以轻松部署的作者插件。</span><span class="sxs-lookup"><span data-stu-id="3bd58-111">Author plugins that can be easily deployed by just copying the build artifacts.</span></span></li>
</ul>
<h2 id="prerequisites" class="heading-anchor"><a class="anchor-link docon docon-link" href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#prerequisites" aria-labelledby="prerequisites"></a><span data-ttu-id="3bd58-112">系统必备</span><span class="sxs-lookup"><span data-stu-id="3bd58-112">Prerequisites</span></span></h2>
<ul>
<li><span data-ttu-id="3bd58-113">安装 <a href="https://dotnet.microsoft.com/download" data-linktype="external">.NET 5 SDK</a> 或更高版本。</span><span class="sxs-lookup"><span data-stu-id="3bd58-113">Install the <a href="https://dotnet.microsoft.com/download" data-linktype="external">.NET 5 SDK</a> or a newer version.</span></span></li>
</ul>
<div class="alert is-info">
<p class="alert-title"><span class="docon docon-status-error-outline" aria-hidden="true"></span> 备注</p>
<p><span data-ttu-id="3bd58-114">示例代码针对 .NET 5，但它使用的所有功能都已在 .NET Core 3.0 中推出，并且在此后所有 .NET 版本中都可用。</span><span class="sxs-lookup"><span data-stu-id="3bd58-114">The sample code targets .NET 5, but all the features it uses were introduced in .NET Core 3.0 and are available in all .NET releases since then.</span></span></p>
</div>
<h2 id="create-the-application" class="heading-anchor"><a class="anchor-link docon docon-link" href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#create-the-application" aria-labelledby="create-the-application"></a><span data-ttu-id="3bd58-115">创建应用程序</span><span class="sxs-lookup"><span data-stu-id="3bd58-115">Create the application</span></span></h2>
<p><span data-ttu-id="3bd58-116">第一步是创建应用程序：</span><span class="sxs-lookup"><span data-stu-id="3bd58-116">The first step is to create the application:</span></span></p>
<ol>
<li><p><span data-ttu-id="3bd58-117">创建新文件夹，并在该文件夹中运行以下命令：</span><span class="sxs-lookup"><span data-stu-id="3bd58-117">Create a new folder, and in that folder run the following command:</span></span></p>
<div class="codeHeader" id="code-try-0" data-bi-name="code-header"><span class="language">.NET Core CLI</span><button type="button" class="action is-relative" data-bi-name="copy" aria-label="复制代码">
				<span class="icon">
					<span class="docon docon-edit-copy" role="presentation"></span>
				</span>
				<span>复制</span>
				<div class="successful-copy-alert is-absolute has-right-zero has-top-zero has-left-zero has-bottom-zero is-flex has-flex-align-items-center has-flex-justify-content-center has-text-success-invert has-background-success is-transparent" aria-hidden="true">
					<span class="icon is-size-large">
						<span class="docon docon-check-mark" role="presentation"></span>
					</span>
				</div>
			</button></div><pre tabindex="0" class="has-inner-focus"><code class="lang-dotnetcli" data-author-content="dotnet new console -o AppWithPlugin
"><span><span class="hljs-keyword">dotnet</span> <span class="hljs-keyword">new</span> console<span class="hljs-parameter"> -o</span> AppWithPlugin
</span></code></pre>
</li>
<li><p><span data-ttu-id="3bd58-118">为了更容易生成项目，请在同一文件夹中创建一个 Visual Studio 解决方案文件。</span><span class="sxs-lookup"><span data-stu-id="3bd58-118">To make building the project easier, create a Visual Studio solution file in the same folder.</span></span> <span data-ttu-id="3bd58-119">运行以下命令：</span><span class="sxs-lookup"><span data-stu-id="3bd58-119">Run the following command:</span></span></p>
<div class="codeHeader" id="code-try-1" data-bi-name="code-header"><span class="language">.NET Core CLI</span><button type="button" class="action is-relative" data-bi-name="copy" aria-label="复制代码">
				<span class="icon">
					<span class="docon docon-edit-copy" role="presentation"></span>
				</span>
				<span>复制</span>
				<div class="successful-copy-alert is-absolute has-right-zero has-top-zero has-left-zero has-bottom-zero is-flex has-flex-align-items-center has-flex-justify-content-center has-text-success-invert has-background-success is-transparent" aria-hidden="true">
					<span class="icon is-size-large">
						<span class="docon docon-check-mark" role="presentation"></span>
					</span>
				</div>
			</button></div><pre tabindex="0" class="has-inner-focus"><code class="lang-dotnetcli" data-author-content="dotnet new sln
"><span><span class="hljs-keyword">dotnet</span> <span class="hljs-keyword">new</span> <span class="hljs-keyword">sln</span>
</span></code></pre>
</li>
<li><p><span data-ttu-id="3bd58-120">运行以下命令，向解决方案添加应用项目：</span><span class="sxs-lookup"><span data-stu-id="3bd58-120">Run the following command to add the app project to the solution:</span></span></p>
<div class="codeHeader" id="code-try-2" data-bi-name="code-header"><span class="language">.NET Core CLI</span><button type="button" class="action is-relative" data-bi-name="copy" aria-label="复制代码">
				<span class="icon">
					<span class="docon docon-edit-copy" role="presentation"></span>
				</span>
				<span>复制</span>
				<div class="successful-copy-alert is-absolute has-right-zero has-top-zero has-left-zero has-bottom-zero is-flex has-flex-align-items-center has-flex-justify-content-center has-text-success-invert has-background-success is-transparent" aria-hidden="true">
					<span class="icon is-size-large">
						<span class="docon docon-check-mark" role="presentation"></span>
					</span>
				</div>
			</button></div><pre tabindex="0" class="has-inner-focus"><code class="lang-dotnetcli" data-author-content="dotnet sln add AppWithPlugin/AppWithPlugin.csproj
"><span><span class="hljs-keyword">dotnet</span> <span class="hljs-keyword">sln</span> <span class="hljs-keyword">add</span> AppWithPlugin/AppWithPlugin.csproj
</span></code></pre>
</li>
</ol>
<p><span data-ttu-id="3bd58-121">现在，我们可以填写应用程序的主干。</span><span class="sxs-lookup"><span data-stu-id="3bd58-121">Now we can fill in the skeleton of our application.</span></span> <span data-ttu-id="3bd58-122">使用下面的代码替换 AppWithPlugin/Program.cs 文件中的代码： </span><span class="sxs-lookup"><span data-stu-id="3bd58-122">Replace the code in the <em>AppWithPlugin/Program.cs</em> file with the following code:</span></span></p>
<div class="codeHeader" id="code-try-3" data-bi-name="code-header"><span class="language">C#</span><button type="button" class="action is-relative" data-bi-name="copy" aria-label="复制代码">
				<span class="icon">
					<span class="docon docon-edit-copy" role="presentation"></span>
				</span>
				<span>复制</span>
				<div class="successful-copy-alert is-absolute has-right-zero has-top-zero has-left-zero has-bottom-zero is-flex has-flex-align-items-center has-flex-justify-content-center has-text-success-invert has-background-success is-transparent" aria-hidden="true">
					<span class="icon is-size-large">
						<span class="docon docon-check-mark" role="presentation"></span>
					</span>
				</div>
			</button></div><pre tabindex="0" class="has-inner-focus"><code class="lang-csharp" data-author-content="using PluginBase;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;

namespace AppWithPlugin
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                if (args.Length == 1 &amp;&amp; args[0] == &quot;/d&quot;)
                {
                    Console.WriteLine(&quot;Waiting for any key...&quot;);
                    Console.ReadLine();
                }

                // Load commands from plugins.

                if (args.Length == 0)
                {
                    Console.WriteLine(&quot;Commands: &quot;);
                    // Output the loaded commands.
                }
                else
                {
                    foreach (string commandName in args)
                    {
                        Console.WriteLine($&quot;-- {commandName} --&quot;);

                        // Execute the command with the name passed as an argument.

                        Console.WriteLine();
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
    }
}

"><span><span class="hljs-keyword">using</span> PluginBase;
<span class="hljs-keyword">using</span> System;
<span class="hljs-keyword">using</span> System.Collections.Generic;
<span class="hljs-keyword">using</span> System.IO;
<span class="hljs-keyword">using</span> System.Linq;
<span class="hljs-keyword">using</span> System.Reflection;

<span class="hljs-keyword">namespace</span> <span class="hljs-title">AppWithPlugin</span>
{
    <span class="hljs-keyword">class</span> <span class="hljs-title">Program</span>
    {
        <span class="hljs-function"><span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">Main</span>(<span class="hljs-params"><span class="hljs-keyword">string</span>[] args</span>)</span>
        {
            <span class="hljs-keyword">try</span>
            {
                <span class="hljs-keyword">if</span> (args.Length == <span class="hljs-number">1</span> &amp;&amp; args[<span class="hljs-number">0</span>] == <span class="hljs-string">"/d"</span>)
                {
                    Console.WriteLine(<span class="hljs-string">"Waiting for any key..."</span>);
                    Console.ReadLine();
                }

                <span class="hljs-comment">// Load commands from plugins.</span>

                <span class="hljs-keyword">if</span> (args.Length == <span class="hljs-number">0</span>)
                {
                    Console.WriteLine(<span class="hljs-string">"Commands: "</span>);
                    <span class="hljs-comment">// Output the loaded commands.</span>
                }
                <span class="hljs-keyword">else</span>
                {
                    <span class="hljs-keyword">foreach</span> (<span class="hljs-keyword">string</span> commandName <span class="hljs-keyword">in</span> args)
                    {
                        Console.WriteLine(<span class="hljs-string">$"-- <span class="hljs-subst">{commandName}</span> --"</span>);

                        <span class="hljs-comment">// Execute the command with the name passed as an argument.</span>

                        Console.WriteLine();
                    }
                }
            }
            <span class="hljs-keyword">catch</span> (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
    }
}

</span></code></pre>
<h2 id="create-the-plugin-interfaces" class="heading-anchor"><a class="anchor-link docon docon-link" href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#create-the-plugin-interfaces" aria-labelledby="create-the-plugin-interfaces"></a><span data-ttu-id="3bd58-123">创建插件接口</span><span class="sxs-lookup"><span data-stu-id="3bd58-123">Create the plugin interfaces</span></span></h2>
<p><span data-ttu-id="3bd58-124">使用插件生成应用的下一步是定义插件需要实现的接口。</span><span class="sxs-lookup"><span data-stu-id="3bd58-124">The next step in building an app with plugins is defining the interface the plugins need to implement.</span></span> <span data-ttu-id="3bd58-125">我们建议创建类库，其中包含计划用于在应用和插件之间通信的任何类型。</span><span class="sxs-lookup"><span data-stu-id="3bd58-125">We suggest that you make a class library that contains any types that you plan to use for communicating between your app and plugins.</span></span> <span data-ttu-id="3bd58-126">此部分允许将插件接口作为包发布，而无需发布完整的应用程序。</span><span class="sxs-lookup"><span data-stu-id="3bd58-126">This division allows you to publish your plugin interface as a package without having to ship your full application.</span></span></p>
<p><span data-ttu-id="3bd58-127">在项目的根文件夹中，运行 <code>dotnet new classlib -o PluginBase</code>。</span><span class="sxs-lookup"><span data-stu-id="3bd58-127">In the root folder of the project, run <code>dotnet new classlib -o PluginBase</code>.</span></span> <span data-ttu-id="3bd58-128">并运行 <code>dotnet sln add PluginBase/PluginBase.csproj</code> 向解决方案文件添加项目。</span><span class="sxs-lookup"><span data-stu-id="3bd58-128">Also, run <code>dotnet sln add PluginBase/PluginBase.csproj</code> to add the project to the solution file.</span></span> <span data-ttu-id="3bd58-129">删除 <code>PluginBase/Class1.cs</code> 文件，并使用以下接口定义在名为 <code>ICommand.cs</code> 的 <code>PluginBase</code> 文件夹中创建新的文件：</span><span class="sxs-lookup"><span data-stu-id="3bd58-129">Delete the <code>PluginBase/Class1.cs</code> file, and create a new file in the <code>PluginBase</code> folder named <code>ICommand.cs</code> with the following interface definition:</span></span></p>
<div class="codeHeader" id="code-try-4" data-bi-name="code-header"><span class="language">C#</span><button type="button" class="action is-relative" data-bi-name="copy" aria-label="复制代码">
				<span class="icon">
					<span class="docon docon-edit-copy" role="presentation"></span>
				</span>
				<span>复制</span>
				<div class="successful-copy-alert is-absolute has-right-zero has-top-zero has-left-zero has-bottom-zero is-flex has-flex-align-items-center has-flex-justify-content-center has-text-success-invert has-background-success is-transparent" aria-hidden="true">
					<span class="icon is-size-large">
						<span class="docon docon-check-mark" role="presentation"></span>
					</span>
				</div>
			</button></div><pre tabindex="0" class="has-inner-focus"><code class="lang-csharp" name="the-plugin-interface" data-author-content="namespace PluginBase
{
    public interface ICommand
    {
        string Name { get; }
        string Description { get; }

        int Execute();
    }
}
"><span><span class="hljs-keyword">namespace</span> <span class="hljs-title">PluginBase</span>
{
    <span class="hljs-keyword">public</span> <span class="hljs-keyword">interface</span> <span class="hljs-title">ICommand</span>
    {
        <span class="hljs-keyword">string</span> Name { <span class="hljs-keyword">get</span>; }
        <span class="hljs-keyword">string</span> Description { <span class="hljs-keyword">get</span>; }

        <span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">Execute</span>(<span class="hljs-params"></span>)</span>;
    }
}
</span></code></pre>
<p><span data-ttu-id="3bd58-130">此 <code>ICommand</code> 接口是所有插件将实现的接口。</span><span class="sxs-lookup"><span data-stu-id="3bd58-130">This <code>ICommand</code> interface is the interface that all of the plugins will implement.</span></span></p>
<p><span data-ttu-id="3bd58-131">由于已定义 <code>ICommand</code> 接口，所以应用程序项目可以填写更多内容。</span><span class="sxs-lookup"><span data-stu-id="3bd58-131">Now that the <code>ICommand</code> interface is defined, the application project can be filled in a little more.</span></span> <span data-ttu-id="3bd58-132">使用根文件夹中的 <code>dotnet add AppWithPlugin/AppWithPlugin.csproj reference PluginBase/PluginBase.csproj</code> 命令将引用从 <code>AppWithPlugin</code> 项目添加到 <code>PluginBase</code> 项目。</span><span class="sxs-lookup"><span data-stu-id="3bd58-132">Add a reference from the <code>AppWithPlugin</code> project to the <code>PluginBase</code> project with the <code>dotnet add AppWithPlugin/AppWithPlugin.csproj reference PluginBase/PluginBase.csproj</code>  command from the root folder.</span></span></p>
<p><span data-ttu-id="3bd58-133">使用以下代码片段替换 <code>// Load commands from plugins</code> 注释，使其能够从给定文件路径加载插件：</span><span class="sxs-lookup"><span data-stu-id="3bd58-133">Replace the <code>// Load commands from plugins</code> comment with the following code snippet to enable it to load plugins from given file paths:</span></span></p>
<div class="codeHeader" id="code-try-5" data-bi-name="code-header"><span class="language">C#</span><button type="button" class="action is-relative" data-bi-name="copy" aria-label="复制代码">
				<span class="icon">
					<span class="docon docon-edit-copy" role="presentation"></span>
				</span>
				<span>复制</span>
				<div class="successful-copy-alert is-absolute has-right-zero has-top-zero has-left-zero has-bottom-zero is-flex has-flex-align-items-center has-flex-justify-content-center has-text-success-invert has-background-success is-transparent" aria-hidden="true">
					<span class="icon is-size-large">
						<span class="docon docon-check-mark" role="presentation"></span>
					</span>
				</div>
			</button></div><pre tabindex="0" class="has-inner-focus"><code class="lang-csharp" data-author-content="string[] pluginPaths = new string[]
{
    // Paths to plugins to load.
};

IEnumerable&lt;ICommand&gt; commands = pluginPaths.SelectMany(pluginPath =&gt;
{
    Assembly pluginAssembly = LoadPlugin(pluginPath);
    return CreateCommands(pluginAssembly);
}).ToList();
"><span><span class="hljs-keyword">string</span>[] pluginPaths = <span class="hljs-keyword">new</span> <span class="hljs-keyword">string</span>[]
{
    <span class="hljs-comment">// Paths to plugins to load.</span>
};

IEnumerable&lt;ICommand&gt; commands = pluginPaths.SelectMany(pluginPath =&gt;
{
    Assembly pluginAssembly = LoadPlugin(pluginPath);
    <span class="hljs-keyword">return</span> CreateCommands(pluginAssembly);
}).ToList();
</span></code></pre>
<p><span data-ttu-id="3bd58-134">然后用以下代码片段替换 <code>// Output the loaded commands</code> 注释：</span><span class="sxs-lookup"><span data-stu-id="3bd58-134">Then replace the <code>// Output the loaded commands</code> comment with the following code snippet:</span></span></p>
<div class="codeHeader" id="code-try-6" data-bi-name="code-header"><span class="language">C#</span><button type="button" class="action is-relative" data-bi-name="copy" aria-label="复制代码">
				<span class="icon">
					<span class="docon docon-edit-copy" role="presentation"></span>
				</span>
				<span>复制</span>
				<div class="successful-copy-alert is-absolute has-right-zero has-top-zero has-left-zero has-bottom-zero is-flex has-flex-align-items-center has-flex-justify-content-center has-text-success-invert has-background-success is-transparent" aria-hidden="true">
					<span class="icon is-size-large">
						<span class="docon docon-check-mark" role="presentation"></span>
					</span>
				</div>
			</button></div><pre tabindex="0" class="has-inner-focus"><code class="lang-csharp" data-author-content="foreach (ICommand command in commands)
{
    Console.WriteLine($&quot;{command.Name}\t - {command.Description}&quot;);
}
"><span><span class="hljs-keyword">foreach</span> (ICommand command <span class="hljs-keyword">in</span> commands)
{
    Console.WriteLine(<span class="hljs-string">$"<span class="hljs-subst">{command.Name}</span>\t - <span class="hljs-subst">{command.Description}</span>"</span>);
}
</span></code></pre>
<p><span data-ttu-id="3bd58-135">使用以下代码片段替换 <code>// Execute the command with the name passed as an argument</code> 注释：</span><span class="sxs-lookup"><span data-stu-id="3bd58-135">Replace the <code>// Execute the command with the name passed as an argument</code> comment with the following snippet:</span></span></p>
<div class="codeHeader" id="code-try-7" data-bi-name="code-header"><span class="language">C#</span><button type="button" class="action is-relative" data-bi-name="copy" aria-label="复制代码">
				<span class="icon">
					<span class="docon docon-edit-copy" role="presentation"></span>
				</span>
				<span>复制</span>
				<div class="successful-copy-alert is-absolute has-right-zero has-top-zero has-left-zero has-bottom-zero is-flex has-flex-align-items-center has-flex-justify-content-center has-text-success-invert has-background-success is-transparent" aria-hidden="true">
					<span class="icon is-size-large">
						<span class="docon docon-check-mark" role="presentation"></span>
					</span>
				</div>
			</button></div><pre tabindex="0" class="has-inner-focus"><code class="lang-csharp" data-author-content="ICommand command = commands.FirstOrDefault(c =&gt; c.Name == commandName);
if (command == null)
{
    Console.WriteLine(&quot;No such command is known.&quot;);
    return;
}

command.Execute();
"><span>ICommand command = commands.FirstOrDefault(c =&gt; c.Name == commandName);
<span class="hljs-keyword">if</span> (command == <span class="hljs-literal">null</span>)
{
    Console.WriteLine(<span class="hljs-string">"No such command is known."</span>);
    <span class="hljs-keyword">return</span>;
}

command.Execute();
</span></code></pre>
<p><span data-ttu-id="3bd58-136">最后，将静态方法添加到名为 <code>LoadPlugin</code> 和 <code>CreateCommands</code> 的 <code>Program</code> 类，如下所示：</span><span class="sxs-lookup"><span data-stu-id="3bd58-136">And finally, add static methods to the <code>Program</code> class named <code>LoadPlugin</code> and <code>CreateCommands</code>, as shown here:</span></span></p>
<div class="codeHeader" id="code-try-8" data-bi-name="code-header"><span class="language">C#</span><button type="button" class="action is-relative" data-bi-name="copy" aria-label="复制代码">
				<span class="icon">
					<span class="docon docon-edit-copy" role="presentation"></span>
				</span>
				<span>复制</span>
				<div class="successful-copy-alert is-absolute has-right-zero has-top-zero has-left-zero has-bottom-zero is-flex has-flex-align-items-center has-flex-justify-content-center has-text-success-invert has-background-success is-transparent" aria-hidden="true">
					<span class="icon is-size-large">
						<span class="docon docon-check-mark" role="presentation"></span>
					</span>
				</div>
			</button></div><pre tabindex="0" class="has-inner-focus"><code class="lang-csharp" data-author-content="static Assembly LoadPlugin(string relativePath)
{
    throw new NotImplementedException();
}

static IEnumerable&lt;ICommand&gt; CreateCommands(Assembly assembly)
{
    int count = 0;

    foreach (Type type in assembly.GetTypes())
    {
        if (typeof(ICommand).IsAssignableFrom(type))
        {
            ICommand result = Activator.CreateInstance(type) as ICommand;
            if (result != null)
            {
                count++;
                yield return result;
            }
        }
    }

    if (count == 0)
    {
        string availableTypes = string.Join(&quot;,&quot;, assembly.GetTypes().Select(t =&gt; t.FullName));
        throw new ApplicationException(
            $&quot;Can&#39;t find any type which implements ICommand in {assembly} from {assembly.Location}.\n&quot; +
            $&quot;Available types: {availableTypes}&quot;);
    }
}
"><span><span class="hljs-function"><span class="hljs-keyword">static</span> Assembly <span class="hljs-title">LoadPlugin</span>(<span class="hljs-params"><span class="hljs-keyword">string</span> relativePath</span>)</span>
{
    <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> NotImplementedException();
}

<span class="hljs-function"><span class="hljs-keyword">static</span> IEnumerable&lt;ICommand&gt; <span class="hljs-title">CreateCommands</span>(<span class="hljs-params">Assembly assembly</span>)</span>
{
    <span class="hljs-keyword">int</span> count = <span class="hljs-number">0</span>;

    <span class="hljs-keyword">foreach</span> (Type type <span class="hljs-keyword">in</span> assembly.GetTypes())
    {
        <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span>(ICommand).IsAssignableFrom(type))
        {
            ICommand result = Activator.CreateInstance(type) <span class="hljs-keyword">as</span> ICommand;
            <span class="hljs-keyword">if</span> (result != <span class="hljs-literal">null</span>)
            {
                count++;
                <span class="hljs-keyword">yield</span> <span class="hljs-keyword">return</span> result;
            }
        }
    }

    <span class="hljs-keyword">if</span> (count == <span class="hljs-number">0</span>)
    {
        <span class="hljs-keyword">string</span> availableTypes = <span class="hljs-keyword">string</span>.Join(<span class="hljs-string">","</span>, assembly.GetTypes().Select(t =&gt; t.FullName));
        <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> ApplicationException(
            <span class="hljs-string">$"Can't find any type which implements ICommand in <span class="hljs-subst">{assembly}</span> from <span class="hljs-subst">{assembly.Location}</span>.\n"</span> +
            <span class="hljs-string">$"Available types: <span class="hljs-subst">{availableTypes}</span>"</span>);
    }
}
</span></code></pre>
<h2 id="load-plugins" class="heading-anchor"><a class="anchor-link docon docon-link" href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#load-plugins" aria-labelledby="load-plugins"></a><span data-ttu-id="3bd58-137">加载插件</span><span class="sxs-lookup"><span data-stu-id="3bd58-137">Load plugins</span></span></h2>
<p><span data-ttu-id="3bd58-138">现在，应用程序可以正确加载和实例化来自已加载的插件程序集的命令，但仍然无法加载插件程序集。</span><span class="sxs-lookup"><span data-stu-id="3bd58-138">Now the application can correctly load and instantiate commands from loaded plugin assemblies, but it's still unable to load the plugin assemblies.</span></span> <span data-ttu-id="3bd58-139">使用以下内容在 AppWithPlugin 文件夹中创建名为 PluginLoadContext.cs 的文件：  </span><span class="sxs-lookup"><span data-stu-id="3bd58-139">Create a file named <em>PluginLoadContext.cs</em> in the <em>AppWithPlugin</em> folder with the following contents:</span></span></p>
<div class="codeHeader" id="code-try-9" data-bi-name="code-header"><span class="language">C#</span><button type="button" class="action is-relative" data-bi-name="copy" aria-label="复制代码">
				<span class="icon">
					<span class="docon docon-edit-copy" role="presentation"></span>
				</span>
				<span>复制</span>
				<div class="successful-copy-alert is-absolute has-right-zero has-top-zero has-left-zero has-bottom-zero is-flex has-flex-align-items-center has-flex-justify-content-center has-text-success-invert has-background-success is-transparent" aria-hidden="true">
					<span class="icon is-size-large">
						<span class="docon docon-check-mark" role="presentation"></span>
					</span>
				</div>
			</button></div><pre tabindex="0" class="has-inner-focus"><code class="lang-csharp" name="loading-plugins" data-author-content="using System;
using System.Reflection;
using System.Runtime.Loader;

namespace AppWithPlugin
{
    class PluginLoadContext : AssemblyLoadContext
    {
        private AssemblyDependencyResolver _resolver;

        public PluginLoadContext(string pluginPath)
        {
            _resolver = new AssemblyDependencyResolver(pluginPath);
        }

        protected override Assembly Load(AssemblyName assemblyName)
        {
            string assemblyPath = _resolver.ResolveAssemblyToPath(assemblyName);
            if (assemblyPath != null)
            {
                return LoadFromAssemblyPath(assemblyPath);
            }

            return null;
        }

        protected override IntPtr LoadUnmanagedDll(string unmanagedDllName)
        {
            string libraryPath = _resolver.ResolveUnmanagedDllToPath(unmanagedDllName);
            if (libraryPath != null)
            {
                return LoadUnmanagedDllFromPath(libraryPath);
            }

            return IntPtr.Zero;
        }
    }
}
"><span><span class="hljs-keyword">using</span> System;
<span class="hljs-keyword">using</span> System.Reflection;
<span class="hljs-keyword">using</span> System.Runtime.Loader;

<span class="hljs-keyword">namespace</span> <span class="hljs-title">AppWithPlugin</span>
{
    <span class="hljs-keyword">class</span> <span class="hljs-title">PluginLoadContext</span> : <span class="hljs-title">AssemblyLoadContext</span>
    {
        <span class="hljs-keyword">private</span> AssemblyDependencyResolver _resolver;

        <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">PluginLoadContext</span>(<span class="hljs-params"><span class="hljs-keyword">string</span> pluginPath</span>)</span>
        {
            _resolver = <span class="hljs-keyword">new</span> AssemblyDependencyResolver(pluginPath);
        }

        <span class="hljs-function"><span class="hljs-keyword">protected</span> <span class="hljs-keyword">override</span> Assembly <span class="hljs-title">Load</span>(<span class="hljs-params">AssemblyName assemblyName</span>)</span>
        {
            <span class="hljs-keyword">string</span> assemblyPath = _resolver.ResolveAssemblyToPath(assemblyName);
            <span class="hljs-keyword">if</span> (assemblyPath != <span class="hljs-literal">null</span>)
            {
                <span class="hljs-keyword">return</span> LoadFromAssemblyPath(assemblyPath);
            }

            <span class="hljs-keyword">return</span> <span class="hljs-literal">null</span>;
        }

        <span class="hljs-function"><span class="hljs-keyword">protected</span> <span class="hljs-keyword">override</span> IntPtr <span class="hljs-title">LoadUnmanagedDll</span>(<span class="hljs-params"><span class="hljs-keyword">string</span> unmanagedDllName</span>)</span>
        {
            <span class="hljs-keyword">string</span> libraryPath = _resolver.ResolveUnmanagedDllToPath(unmanagedDllName);
            <span class="hljs-keyword">if</span> (libraryPath != <span class="hljs-literal">null</span>)
            {
                <span class="hljs-keyword">return</span> LoadUnmanagedDllFromPath(libraryPath);
            }

            <span class="hljs-keyword">return</span> IntPtr.Zero;
        }
    }
}
</span></code></pre>
<p><span data-ttu-id="3bd58-140"><code>PluginLoadContext</code> 类型派生自 <a href="https://docs.microsoft.com/zh-cn/dotnet/api/system.runtime.loader.assemblyloadcontext" data-linktype="absolute-path">AssemblyLoadContext</a>。</span><span class="sxs-lookup"><span data-stu-id="3bd58-140">The <code>PluginLoadContext</code> type derives from <a href="https://docs.microsoft.com/zh-cn/dotnet/api/system.runtime.loader.assemblyloadcontext" data-linktype="absolute-path">AssemblyLoadContext</a>.</span></span> <span data-ttu-id="3bd58-141"><code>AssemblyLoadContext</code> 类型是运行时中的特殊类型，该类型允许开发人员将已加载的程序集隔离到不同的组中，以确保程序集版本不冲突。</span><span class="sxs-lookup"><span data-stu-id="3bd58-141">The <code>AssemblyLoadContext</code> type is a special type in the runtime that allows developers to isolate loaded assemblies into different groups to ensure that assembly versions don't conflict.</span></span> <span data-ttu-id="3bd58-142">此外，自定义 <code>AssemblyLoadContext</code> 可以选择不同路径来加载程序集格式并重写默认行为。</span><span class="sxs-lookup"><span data-stu-id="3bd58-142">Additionally, a custom <code>AssemblyLoadContext</code> can choose different paths to load assemblies from and override the default behavior.</span></span> <span data-ttu-id="3bd58-143"><code>PluginLoadContext</code> 使用 .NET Core 3.0 中引入的 <code>AssemblyDependencyResolver</code> 类型的实例将程序集名称解析为路径。</span><span class="sxs-lookup"><span data-stu-id="3bd58-143">The <code>PluginLoadContext</code> uses an instance of the <code>AssemblyDependencyResolver</code> type introduced in .NET Core 3.0 to resolve assembly names to paths.</span></span> <span data-ttu-id="3bd58-144"><code>AssemblyDependencyResolver</code> 对象是使用 .NET 类库的路径构造的。</span><span class="sxs-lookup"><span data-stu-id="3bd58-144">The <code>AssemblyDependencyResolver</code> object is constructed with the path to a .NET class library.</span></span> <span data-ttu-id="3bd58-145">它根据类库的 .deps.json 文件（其路径传递给 <code>AssemblyDependencyResolver</code> 构造函数）将程序集和本机库解析为它们的相对路径。</span><span class="sxs-lookup"><span data-stu-id="3bd58-145">It resolves assemblies and native libraries to their relative paths based on the <em>.deps.json</em> file for the class library whose path was passed to the <code>AssemblyDependencyResolver</code> constructor.</span></span> <span data-ttu-id="3bd58-146">自定义 <code>AssemblyLoadContext</code> 使插件能够拥有自己的依赖项，<code>AssemblyDependencyResolver</code> 使正确加载依赖项变得容易。</span><span class="sxs-lookup"><span data-stu-id="3bd58-146">The custom <code>AssemblyLoadContext</code> enables plugins to have their own dependencies, and the <code>AssemblyDependencyResolver</code> makes it easy to correctly load the dependencies.</span></span></p>
<p><span data-ttu-id="3bd58-147">由于 <code>AppWithPlugin</code> 项目具有 <code>PluginLoadContext</code> 类型，所以请使用以下正文更新 <code>Program.LoadPlugin</code> 方法：</span><span class="sxs-lookup"><span data-stu-id="3bd58-147">Now that the <code>AppWithPlugin</code> project has the <code>PluginLoadContext</code> type, update the <code>Program.LoadPlugin</code> method with the following body:</span></span></p>
<div class="codeHeader" id="code-try-10" data-bi-name="code-header"><span class="language">C#</span><button type="button" class="action is-relative" data-bi-name="copy" aria-label="复制代码">
				<span class="icon">
					<span class="docon docon-edit-copy" role="presentation"></span>
				</span>
				<span>复制</span>
				<div class="successful-copy-alert is-absolute has-right-zero has-top-zero has-left-zero has-bottom-zero is-flex has-flex-align-items-center has-flex-justify-content-center has-text-success-invert has-background-success is-transparent" aria-hidden="true">
					<span class="icon is-size-large">
						<span class="docon docon-check-mark" role="presentation"></span>
					</span>
				</div>
			</button></div><pre tabindex="0" class="has-inner-focus"><code class="lang-csharp" data-author-content="static Assembly LoadPlugin(string relativePath)
{
    // Navigate up to the solution root
    string root = Path.GetFullPath(Path.Combine(
        Path.GetDirectoryName(
            Path.GetDirectoryName(
                Path.GetDirectoryName(
                    Path.GetDirectoryName(
                        Path.GetDirectoryName(typeof(Program).Assembly.Location)))))));

    string pluginLocation = Path.GetFullPath(Path.Combine(root, relativePath.Replace(&#39;\\&#39;, Path.DirectorySeparatorChar)));
    Console.WriteLine($&quot;Loading commands from: {pluginLocation}&quot;);
    PluginLoadContext loadContext = new PluginLoadContext(pluginLocation);
    return loadContext.LoadFromAssemblyName(new AssemblyName(Path.GetFileNameWithoutExtension(pluginLocation)));
}
"><span><span class="hljs-function"><span class="hljs-keyword">static</span> Assembly <span class="hljs-title">LoadPlugin</span>(<span class="hljs-params"><span class="hljs-keyword">string</span> relativePath</span>)</span>
{
    <span class="hljs-comment">// Navigate up to the solution root</span>
    <span class="hljs-keyword">string</span> root = Path.GetFullPath(Path.Combine(
        Path.GetDirectoryName(
            Path.GetDirectoryName(
                Path.GetDirectoryName(
                    Path.GetDirectoryName(
                        Path.GetDirectoryName(<span class="hljs-keyword">typeof</span>(Program).Assembly.Location)))))));

    <span class="hljs-keyword">string</span> pluginLocation = Path.GetFullPath(Path.Combine(root, relativePath.Replace(<span class="hljs-string">'\\'</span>, Path.DirectorySeparatorChar)));
    Console.WriteLine(<span class="hljs-string">$"Loading commands from: <span class="hljs-subst">{pluginLocation}</span>"</span>);
    PluginLoadContext loadContext = <span class="hljs-keyword">new</span> PluginLoadContext(pluginLocation);
    <span class="hljs-keyword">return</span> loadContext.LoadFromAssemblyName(<span class="hljs-keyword">new</span> AssemblyName(Path.GetFileNameWithoutExtension(pluginLocation)));
}
</span></code></pre>
<p><span data-ttu-id="3bd58-148">通过为每个插件使用不同的 <code>PluginLoadContext</code> 实例，插件可以具有不同的甚至冲突的依赖项，而不会出现问题。</span><span class="sxs-lookup"><span data-stu-id="3bd58-148">By using a different <code>PluginLoadContext</code> instance for each plugin, the plugins can have different or even conflicting dependencies without issue.</span></span></p>
<h2 id="simple-plugin-with-no-dependencies" class="heading-anchor"><a class="anchor-link docon docon-link" href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#simple-plugin-with-no-dependencies" aria-labelledby="simple-plugin-with-no-dependencies"></a><span data-ttu-id="3bd58-149">不具有依赖项的简单插件</span><span class="sxs-lookup"><span data-stu-id="3bd58-149">Simple plugin with no dependencies</span></span></h2>
<p><span data-ttu-id="3bd58-150">返回到根文件夹，执行以下步骤：</span><span class="sxs-lookup"><span data-stu-id="3bd58-150">Back in the root folder, do the following:</span></span></p>
<ol>
<li><p><span data-ttu-id="3bd58-151">运行以下命令，新建一个名为 <code>HelloPlugin</code> 的类库项目：</span><span class="sxs-lookup"><span data-stu-id="3bd58-151">Run the following command to create a new class library project named <code>HelloPlugin</code>:</span></span></p>
<div class="codeHeader" id="code-try-11" data-bi-name="code-header"><span class="language">.NET Core CLI</span><button type="button" class="action is-relative" data-bi-name="copy" aria-label="复制代码">
				<span class="icon">
					<span class="docon docon-edit-copy" role="presentation"></span>
				</span>
				<span>复制</span>
				<div class="successful-copy-alert is-absolute has-right-zero has-top-zero has-left-zero has-bottom-zero is-flex has-flex-align-items-center has-flex-justify-content-center has-text-success-invert has-background-success is-transparent" aria-hidden="true">
					<span class="icon is-size-large">
						<span class="docon docon-check-mark" role="presentation"></span>
					</span>
				</div>
			</button></div><pre tabindex="0" class="has-inner-focus"><code class="lang-dotnetcli" data-author-content="dotnet new classlib -o HelloPlugin
"><span><span class="hljs-keyword">dotnet</span> <span class="hljs-keyword">new</span> classlib<span class="hljs-parameter"> -o</span> HelloPlugin
</span></code></pre>
</li>
<li><p><span data-ttu-id="3bd58-152">运行以下命令，将项目添加到 <code>AppWithPlugin</code> 解决方案中：</span><span class="sxs-lookup"><span data-stu-id="3bd58-152">Run the following command to add the project to the <code>AppWithPlugin</code> solution:</span></span></p>
<div class="codeHeader" id="code-try-12" data-bi-name="code-header"><span class="language">.NET Core CLI</span><button type="button" class="action is-relative" data-bi-name="copy" aria-label="复制代码">
				<span class="icon">
					<span class="docon docon-edit-copy" role="presentation"></span>
				</span>
				<span>复制</span>
				<div class="successful-copy-alert is-absolute has-right-zero has-top-zero has-left-zero has-bottom-zero is-flex has-flex-align-items-center has-flex-justify-content-center has-text-success-invert has-background-success is-transparent" aria-hidden="true">
					<span class="icon is-size-large">
						<span class="docon docon-check-mark" role="presentation"></span>
					</span>
				</div>
			</button></div><pre tabindex="0" class="has-inner-focus"><code class="lang-dotnetcli" data-author-content="dotnet sln add HelloPlugin/HelloPlugin.csproj
"><span><span class="hljs-keyword">dotnet</span> <span class="hljs-keyword">sln</span> <span class="hljs-keyword">add</span> HelloPlugin/HelloPlugin.csproj
</span></code></pre>
</li>
<li><p><span data-ttu-id="3bd58-153">使用以下内容将 HelloPlugin/Class1.cs 文件替换为名为 HelloCommand.cs 的文件：  </span><span class="sxs-lookup"><span data-stu-id="3bd58-153">Replace the <em>HelloPlugin/Class1.cs</em> file with a file named <em>HelloCommand.cs</em> with the following contents:</span></span></p>
</li>
</ol>
<div class="codeHeader" id="code-try-13" data-bi-name="code-header"><span class="language">C#</span><button type="button" class="action is-relative" data-bi-name="copy" aria-label="复制代码">
				<span class="icon">
					<span class="docon docon-edit-copy" role="presentation"></span>
				</span>
				<span>复制</span>
				<div class="successful-copy-alert is-absolute has-right-zero has-top-zero has-left-zero has-bottom-zero is-flex has-flex-align-items-center has-flex-justify-content-center has-text-success-invert has-background-success is-transparent" aria-hidden="true">
					<span class="icon is-size-large">
						<span class="docon docon-check-mark" role="presentation"></span>
					</span>
				</div>
			</button></div><pre tabindex="0" class="has-inner-focus"><code class="lang-csharp" name="the-hello-plugin" data-author-content="using PluginBase;
using System;

namespace HelloPlugin
{
    public class HelloCommand : ICommand
    {
        public string Name { get =&gt; &quot;hello&quot;; }
        public string Description { get =&gt; &quot;Displays hello message.&quot;; }

        public int Execute()
        {
            Console.WriteLine(&quot;Hello !!!&quot;);
            return 0;
        }
    }
}
"><span><span class="hljs-keyword">using</span> PluginBase;
<span class="hljs-keyword">using</span> System;

<span class="hljs-keyword">namespace</span> <span class="hljs-title">HelloPlugin</span>
{
    <span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">HelloCommand</span> : <span class="hljs-title">ICommand</span>
    {
        <span class="hljs-keyword">public</span> <span class="hljs-keyword">string</span> Name { <span class="hljs-keyword">get</span> =&gt; <span class="hljs-string">"hello"</span>; }
        <span class="hljs-keyword">public</span> <span class="hljs-keyword">string</span> Description { <span class="hljs-keyword">get</span> =&gt; <span class="hljs-string">"Displays hello message."</span>; }

        <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">int</span> <span class="hljs-title">Execute</span>(<span class="hljs-params"></span>)</span>
        {
            Console.WriteLine(<span class="hljs-string">"Hello !!!"</span>);
            <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
        }
    }
}
</span></code></pre>
<p><span data-ttu-id="3bd58-154">现在，打开 HelloPlugin.csproj 文件  。</span><span class="sxs-lookup"><span data-stu-id="3bd58-154">Now, open the <em>HelloPlugin.csproj</em> file.</span></span> <span data-ttu-id="3bd58-155">它应类似于以下内容：</span><span class="sxs-lookup"><span data-stu-id="3bd58-155">It should look similar to the following:</span></span></p>
<div class="codeHeader" id="code-try-14" data-bi-name="code-header"><span class="language">XML</span><button type="button" class="action is-relative" data-bi-name="copy" aria-label="复制代码">
				<span class="icon">
					<span class="docon docon-edit-copy" role="presentation"></span>
				</span>
				<span>复制</span>
				<div class="successful-copy-alert is-absolute has-right-zero has-top-zero has-left-zero has-bottom-zero is-flex has-flex-align-items-center has-flex-justify-content-center has-text-success-invert has-background-success is-transparent" aria-hidden="true">
					<span class="icon is-size-large">
						<span class="docon docon-check-mark" role="presentation"></span>
					</span>
				</div>
			</button></div><pre tabindex="0" class="has-inner-focus"><code class="lang-xml" data-author-content="&lt;Project Sdk=&quot;Microsoft.NET.Sdk&quot;&gt;

  &lt;PropertyGroup&gt;
    &lt;TargetFramework&gt;net5&lt;/TargetFramework&gt;
  &lt;/PropertyGroup&gt;

&lt;/Project&gt;

"><span><span class="hljs-tag">&lt;<span class="hljs-name">Project</span> <span class="hljs-attr">Sdk</span>=<span class="hljs-string">"Microsoft.NET.Sdk"</span>&gt;</span>

  <span class="hljs-tag">&lt;<span class="hljs-name">PropertyGroup</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">TargetFramework</span>&gt;</span>net5<span class="hljs-tag">&lt;/<span class="hljs-name">TargetFramework</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">PropertyGroup</span>&gt;</span>

<span class="hljs-tag">&lt;/<span class="hljs-name">Project</span>&gt;</span>

</span></code></pre>
<p><span data-ttu-id="3bd58-156">在 <code>&lt;Project&gt;</code> 标记之间添加以下元素：</span><span class="sxs-lookup"><span data-stu-id="3bd58-156">In between the <code>&lt;Project&gt;</code> tags, add the following elements:</span></span></p>
<div class="codeHeader" id="code-try-15" data-bi-name="code-header"><span class="language">XML</span><button type="button" class="action is-relative" data-bi-name="copy" aria-label="复制代码">
				<span class="icon">
					<span class="docon docon-edit-copy" role="presentation"></span>
				</span>
				<span>复制</span>
				<div class="successful-copy-alert is-absolute has-right-zero has-top-zero has-left-zero has-bottom-zero is-flex has-flex-align-items-center has-flex-justify-content-center has-text-success-invert has-background-success is-transparent" aria-hidden="true">
					<span class="icon is-size-large">
						<span class="docon docon-check-mark" role="presentation"></span>
					</span>
				</div>
			</button></div><pre tabindex="0" class="has-inner-focus"><code class="lang-xml" data-author-content="&lt;ItemGroup&gt;
    &lt;ProjectReference Include=&quot;..\PluginBase\PluginBase.csproj&quot;&gt;
        &lt;Private&gt;false&lt;/Private&gt;
        &lt;ExcludeAssets&gt;runtime&lt;/ExcludeAssets&gt;
    &lt;/ProjectReference&gt;
&lt;/ItemGroup&gt;
"><span><span class="hljs-tag">&lt;<span class="hljs-name">ItemGroup</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">ProjectReference</span> <span class="hljs-attr">Include</span>=<span class="hljs-string">"..\PluginBase\PluginBase.csproj"</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">Private</span>&gt;</span>false<span class="hljs-tag">&lt;/<span class="hljs-name">Private</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">ExcludeAssets</span>&gt;</span>runtime<span class="hljs-tag">&lt;/<span class="hljs-name">ExcludeAssets</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">ProjectReference</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">ItemGroup</span>&gt;</span>
</span></code></pre>
<p><span data-ttu-id="3bd58-157"><code>&lt;Private&gt;false&lt;/Private&gt;</code> 元素很重要。</span><span class="sxs-lookup"><span data-stu-id="3bd58-157">The <code>&lt;Private&gt;false&lt;/Private&gt;</code> element is important.</span></span> <span data-ttu-id="3bd58-158">它告知 MSBuild 不要将 PluginBase.dll 复制到 HelloPlugin 的输出目录  。</span><span class="sxs-lookup"><span data-stu-id="3bd58-158">This tells MSBuild to not copy <em>PluginBase.dll</em> to the output directory for HelloPlugin.</span></span> <span data-ttu-id="3bd58-159">如果 PluginBase.dll 程序集出现在输出目录中，<code>PluginLoadContext</code> 将在那里查找到该程序集并在加载 HelloPlugin.dll 程序集时加载它。</span><span class="sxs-lookup"><span data-stu-id="3bd58-159">If the <em>PluginBase.dll</em> assembly is present in the output directory, <code>PluginLoadContext</code> will find the assembly there and load it when it loads the <em>HelloPlugin.dll</em> assembly.</span></span> <span data-ttu-id="3bd58-160">此时，<code>HelloPlugin.HelloCommand</code> 类型将从 <code>HelloPlugin</code> 项目的输出目录中的 PluginBase.dll 实现 <code>ICommand</code> 接口，而不是加载到默认加载上下文中的 <code>ICommand</code> 接口。</span><span class="sxs-lookup"><span data-stu-id="3bd58-160">At this point, the <code>HelloPlugin.HelloCommand</code> type will implement the <code>ICommand</code> interface from the <em>PluginBase.dll</em> in the output directory of the <code>HelloPlugin</code> project, not the <code>ICommand</code> interface that is loaded into the default load context.</span></span> <span data-ttu-id="3bd58-161">因为运行时将这两种类型视为不同程序集的不同类型，所以 <code>AppWithPlugin.Program.CreateCommands</code> 方法找不到命令。</span><span class="sxs-lookup"><span data-stu-id="3bd58-161">Since the runtime sees these two types as different types from different assemblies, the <code>AppWithPlugin.Program.CreateCommands</code> method won't find the commands.</span></span> <span data-ttu-id="3bd58-162">因此，对包含插件接口的程序集的引用需要 <code>&lt;Private&gt;false&lt;/Private&gt;</code> 元数据。</span><span class="sxs-lookup"><span data-stu-id="3bd58-162">As a result, the <code>&lt;Private&gt;false&lt;/Private&gt;</code> metadata is required for the reference to the assembly containing the plugin interfaces.</span></span></p>
<p><span data-ttu-id="3bd58-163">同样，如果 <code>PluginBase</code> 引用其他包，则 <code>&lt;ExcludeAssets&gt;runtime&lt;/ExcludeAssets&gt;</code> 元素也很重要。</span><span class="sxs-lookup"><span data-stu-id="3bd58-163">Similarly, the <code>&lt;ExcludeAssets&gt;runtime&lt;/ExcludeAssets&gt;</code> element is also important if the <code>PluginBase</code> references other packages.</span></span> <span data-ttu-id="3bd58-164">此设置与 <code>&lt;Private&gt;false&lt;/Private&gt;</code> 的效果相同，但适用于 <code>PluginBase</code> 项目或它的某个依赖项可能包括的包引用。</span><span class="sxs-lookup"><span data-stu-id="3bd58-164">This setting has the same effect as <code>&lt;Private&gt;false&lt;/Private&gt;</code> but works on package references that the <code>PluginBase</code> project or one of its dependencies may include.</span></span></p>
<p><span data-ttu-id="3bd58-165">因为 <code>HelloPlugin</code> 项目已完成，所以应该更新 <code>AppWithPlugin</code> 项目，以确认可以找到 <code>HelloPlugin</code> 插件的位置。</span><span class="sxs-lookup"><span data-stu-id="3bd58-165">Now that the <code>HelloPlugin</code> project is complete, you should update the <code>AppWithPlugin</code> project to know where the <code>HelloPlugin</code> plugin can be found.</span></span> <span data-ttu-id="3bd58-166">在 <code>// Paths to plugins to load</code> 注释后，添加 <code>@"HelloPlugin\bin\Debug\netcoreapp3.0\HelloPlugin.dll"</code>（根据所使用的 .NET Core 版本，此路径可能有所不同）作为 <code>pluginPaths</code> 数组的元素。</span><span class="sxs-lookup"><span data-stu-id="3bd58-166">After the <code>// Paths to plugins to load</code> comment, add <code>@"HelloPlugin\bin\Debug\netcoreapp3.0\HelloPlugin.dll"</code> (this path could be different based on the .NET Core version you use) as an element of the <code>pluginPaths</code> array.</span></span></p>
<h2 id="plugin-with-library-dependencies" class="heading-anchor"><a class="anchor-link docon docon-link" href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#plugin-with-library-dependencies" aria-labelledby="plugin-with-library-dependencies"></a><span data-ttu-id="3bd58-167">具有库依赖项的插件</span><span class="sxs-lookup"><span data-stu-id="3bd58-167">Plugin with library dependencies</span></span></h2>
<p><span data-ttu-id="3bd58-168">几乎所有插件都比简单的“Hello World”更复杂，而且许多插件都具有其他库上的依赖项。</span><span class="sxs-lookup"><span data-stu-id="3bd58-168">Almost all plugins are more complex than a simple "Hello World", and many plugins have dependencies on other libraries.</span></span> <span data-ttu-id="3bd58-169">示例中的 <code>JsonPlugin</code> 和 <code>OldJson</code> 插件项目显示了具有 <code>Newtonsoft.Json</code> 上的 NuGet 包依赖项的两个插件示例。</span><span class="sxs-lookup"><span data-stu-id="3bd58-169">The <code>JsonPlugin</code> and <code>OldJson</code> plugin projects in the sample show two examples of plugins with NuGet package dependencies on <code>Newtonsoft.Json</code>.</span></span> <span data-ttu-id="3bd58-170">项目文件本身没有关于项目引用的任何特殊信息，并且（在将插件路径添加到 <code>pluginPaths</code> 数组之后）即使是在 AppWithPlugin 应用的同一执行中运行，插件也能完美运行。</span><span class="sxs-lookup"><span data-stu-id="3bd58-170">The project files themselves don't have any special information for the project references, and (after adding the plugin paths to the <code>pluginPaths</code> array) the plugins run perfectly, even if run in the same execution of the AppWithPlugin app.</span></span> <span data-ttu-id="3bd58-171">但是，这些项目不会将引用的程序集复制到它们的输出目录中，因此需要将这些程序集显示在用户的计算机上，以便插件能够正常工作。</span><span class="sxs-lookup"><span data-stu-id="3bd58-171">However, these projects don't copy the referenced assemblies to their output directory, so the assemblies need to be present on the user's machine for the plugins to work.</span></span> <span data-ttu-id="3bd58-172">解决此问题有两种方法。</span><span class="sxs-lookup"><span data-stu-id="3bd58-172">There are two ways to work around this problem.</span></span> <span data-ttu-id="3bd58-173">第一种是使用 <code>dotnet publish</code> 命令发布类库。</span><span class="sxs-lookup"><span data-stu-id="3bd58-173">The first option is to use the <code>dotnet publish</code> command to publish the class library.</span></span> <span data-ttu-id="3bd58-174">或者，如果希望能够将 <code>dotnet build</code> 的输出用于插件，可以在插件的项目文件中的 <code>&lt;PropertyGroup&gt;</code> 标记之间添加 <code>&lt;CopyLocalLockFileAssemblies&gt;true&lt;/CopyLocalLockFileAssemblies&gt;</code> 属性。</span><span class="sxs-lookup"><span data-stu-id="3bd58-174">Alternatively, if you want to be able to use the output of <code>dotnet build</code> for your plugin, you can add the <code>&lt;CopyLocalLockFileAssemblies&gt;true&lt;/CopyLocalLockFileAssemblies&gt;</code> property between the <code>&lt;PropertyGroup&gt;</code> tags in the plugin's project file.</span></span> <span data-ttu-id="3bd58-175">有关示例，请参阅 <code>XcopyablePlugin</code> 插件项目。</span><span class="sxs-lookup"><span data-stu-id="3bd58-175">See the <code>XcopyablePlugin</code> plugin project for an example.</span></span></p>
<h2 id="other-examples-in-the-sample" class="heading-anchor"><a class="anchor-link docon docon-link" href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#other-examples-in-the-sample" aria-labelledby="other-examples-in-the-sample"></a><span data-ttu-id="3bd58-176">示例中的其他示例</span><span class="sxs-lookup"><span data-stu-id="3bd58-176">Other examples in the sample</span></span></h2>
<p><span data-ttu-id="3bd58-177">可以在 <a href="https://github.com/dotnet/samples/tree/master/core/extensions/AppWithPlugin" data-linktype="external">dotnet/samples 存储库</a>中找到本教程的完整源代码。</span><span class="sxs-lookup"><span data-stu-id="3bd58-177">The complete source code for this tutorial can be found in <a href="https://github.com/dotnet/samples/tree/master/core/extensions/AppWithPlugin" data-linktype="external">the dotnet/samples repository</a>.</span></span> <span data-ttu-id="3bd58-178">完成的示例包括 <code>AssemblyDependencyResolver</code> 行为的一些其他示例。</span><span class="sxs-lookup"><span data-stu-id="3bd58-178">The completed sample includes a few other examples of <code>AssemblyDependencyResolver</code> behavior.</span></span> <span data-ttu-id="3bd58-179">例如，<code>AssemblyDependencyResolver</code> 对象还可以解析本机库和 NuGet 包中所包含的已本地化的附属程序集。</span><span class="sxs-lookup"><span data-stu-id="3bd58-179">For example, the <code>AssemblyDependencyResolver</code> object can also resolve native libraries as well as localized satellite assemblies included in NuGet packages.</span></span> <span data-ttu-id="3bd58-180">示例存储库中的 <code>UVPlugin</code> 和 <code>FrenchPlugin</code> 演示了这些方案。</span><span class="sxs-lookup"><span data-stu-id="3bd58-180">The <code>UVPlugin</code> and <code>FrenchPlugin</code> in the samples repository demonstrate these scenarios.</span></span></p>
<h2 id="reference-a-plugin-interface-from-a-nuget-package" class="heading-anchor"><a class="anchor-link docon docon-link" href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#reference-a-plugin-interface-from-a-nuget-package" aria-labelledby="reference-a-plugin-interface-from-a-nuget-package"></a><span data-ttu-id="3bd58-181">从 NuGet 包引用插件接口</span><span class="sxs-lookup"><span data-stu-id="3bd58-181">Reference a plugin interface from a NuGet package</span></span></h2>
<p><span data-ttu-id="3bd58-182">假设存在应用 A，它具有 NuGet 包（名为 <code>A.PluginBase</code>）中定义的插件接口。</span><span class="sxs-lookup"><span data-stu-id="3bd58-182">Let's say that there is an app A that has a plugin interface defined in the NuGet package named <code>A.PluginBase</code>.</span></span> <span data-ttu-id="3bd58-183">如何在插件项目中正确引用包？</span><span class="sxs-lookup"><span data-stu-id="3bd58-183">How do you reference the package correctly in your plugin project?</span></span> <span data-ttu-id="3bd58-184">对于项目引用，使用项目文件的 <code>ProjectReference</code> 元素上的 <code>&lt;Private&gt;false&lt;/Private&gt;</code> 元数据会阻止将 dll 复制到输出。</span><span class="sxs-lookup"><span data-stu-id="3bd58-184">For project references, using the <code>&lt;Private&gt;false&lt;/Private&gt;</code> metadata on the <code>ProjectReference</code> element in the project file prevented the dll from being copied to the output.</span></span></p>
<p><span data-ttu-id="3bd58-185">若要正确引用 <code>A.PluginBase</code> 包，应将项目文件中的 <code>&lt;PackageReference&gt;</code> 元素更改为以下内容：</span><span class="sxs-lookup"><span data-stu-id="3bd58-185">To correctly reference the <code>A.PluginBase</code> package, you want to change the <code>&lt;PackageReference&gt;</code> element in the project file to the following:</span></span></p>
<div class="codeHeader" id="code-try-16" data-bi-name="code-header"><span class="language">XML</span><button type="button" class="action is-relative" data-bi-name="copy" aria-label="复制代码">
				<span class="icon">
					<span class="docon docon-edit-copy" role="presentation"></span>
				</span>
				<span>复制</span>
				<div class="successful-copy-alert is-absolute has-right-zero has-top-zero has-left-zero has-bottom-zero is-flex has-flex-align-items-center has-flex-justify-content-center has-text-success-invert has-background-success is-transparent" aria-hidden="true">
					<span class="icon is-size-large">
						<span class="docon docon-check-mark" role="presentation"></span>
					</span>
				</div>
			</button></div><pre tabindex="0" class="has-inner-focus"><code class="lang-xml" data-author-content="&lt;PackageReference Include=&quot;A.PluginBase&quot; Version=&quot;1.0.0&quot;&gt;
    &lt;ExcludeAssets&gt;runtime&lt;/ExcludeAssets&gt;
&lt;/PackageReference&gt;
"><span><span class="hljs-tag">&lt;<span class="hljs-name">PackageReference</span> <span class="hljs-attr">Include</span>=<span class="hljs-string">"A.PluginBase"</span> <span class="hljs-attr">Version</span>=<span class="hljs-string">"1.0.0"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">ExcludeAssets</span>&gt;</span>runtime<span class="hljs-tag">&lt;/<span class="hljs-name">ExcludeAssets</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">PackageReference</span>&gt;</span>
</span></code></pre>
<p><span data-ttu-id="3bd58-186">此操作会阻止将 <code>A.PluginBase</code> 程序集复制到插件的输出目录，并确保插件将使用 A 版本的 <code>A.PluginBase</code>。</span><span class="sxs-lookup"><span data-stu-id="3bd58-186">This prevents the <code>A.PluginBase</code> assemblies from being copied to the output directory of your plugin and ensures that your plugin will use A's version of <code>A.PluginBase</code>.</span></span></p>
<h2 id="plugin-target-framework-recommendations" class="heading-anchor"><a class="anchor-link docon docon-link" href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#plugin-target-framework-recommendations" aria-labelledby="plugin-target-framework-recommendations"></a><span data-ttu-id="3bd58-187">插件目标框架建议</span><span class="sxs-lookup"><span data-stu-id="3bd58-187">Plugin target framework recommendations</span></span></h2>
<p><span data-ttu-id="3bd58-188">因为插件依赖项加载使用 .deps.json 文件，所以存在一个与插件的目标框架相关的问题  。</span><span class="sxs-lookup"><span data-stu-id="3bd58-188">Because plugin dependency loading uses the <em>.deps.json</em> file, there is a gotcha related to the plugin's target framework.</span></span> <span data-ttu-id="3bd58-189">具体来说，插件应该以运行时为目标，比如 .NET 5，而不是某一版本的 .NET Standard。</span><span class="sxs-lookup"><span data-stu-id="3bd58-189">Specifically, your plugins should target a runtime, such as .NET 5, instead of a version of .NET Standard.</span></span> <span data-ttu-id="3bd58-190">.deps.json  文件基于项目所针对的框架生成，而且由于许多与 .NET Standard 兼容的包提供了用于针对 .NET Standard 进行生成的引用程序集和用于特定运行时的实现程序集，因此 .deps.json  可能无法正确查看实现程序集，或者它可能会获取 .NET Standard 版本的程序集，而不是期望的 .NET Core 版本的程序集。</span><span class="sxs-lookup"><span data-stu-id="3bd58-190">The <em>.deps.json</em> file is generated based on which framework the project targets, and since many .NET Standard-compatible packages ship reference assemblies for building against .NET Standard and implementation assemblies for specific runtimes, the <em>.deps.json</em> may not correctly see implementation assemblies, or it may grab the .NET Standard version of an assembly instead of the .NET Core version you expect.</span></span></p>
<h2 id="plugin-framework-references" class="heading-anchor"><a class="anchor-link docon docon-link" href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#plugin-framework-references" aria-labelledby="plugin-framework-references"></a><span data-ttu-id="3bd58-191">插件框架引用</span><span class="sxs-lookup"><span data-stu-id="3bd58-191">Plugin framework references</span></span></h2>
<p><span data-ttu-id="3bd58-192">插件当前无法向该过程引入新的框架。</span><span class="sxs-lookup"><span data-stu-id="3bd58-192">Currently, plugins can't introduce new frameworks into the process.</span></span> <span data-ttu-id="3bd58-193">例如，无法将使用 <code>Microsoft.AspNetCore.App</code> 框架的插件加载到只使用根 <code>Microsoft.NETCore.App</code> 框架的应用程序中。</span><span class="sxs-lookup"><span data-stu-id="3bd58-193">For example, you can't load a plugin that uses the <code>Microsoft.AspNetCore.App</code> framework into an application that only uses the root <code>Microsoft.NETCore.App</code> framework.</span></span> <span data-ttu-id="3bd58-194">主机应用程序必须声明对插件所需的全部框架的引用。</span><span class="sxs-lookup"><span data-stu-id="3bd58-194">The host application must declare references to all frameworks needed by plugins.</span></span></p>

						<!-- </content> -->

						</main>

						<!-- page rating section -->
								<div class="is-hidden-desktop has-border-top has-margin-top-large has-padding-top-large binary-rating-holder">
									
	
	

	<div class="feedback-verbatim has-border-bottom has-padding-bottom-large has-margin-bottom-small" data-bi-name="rating">
    <div class="binary-rating">
        <div class="binary-rating-buttons">
				<h3 class="has-text-weight-semibold has-margin-top-none has-margin-bottom-small is-size-h4 has-margin-bottom-medium">此页面有帮助吗?</h3>
			<div>
                <button class="thumb-rating like has-inner-focus" title="是" data-bi-name="rating-yes" aria-expanded="false" data-bi-sat="1" aria-controls="rating-container-desktop">
                    <span aria-hidden="true" class="icon docon docon-like"></span>
                    <span>是</span>
                </button>
                <button class="thumb-rating dislike has-inner-focus" title="否" data-bi-name="rating-no" data-bi-sat="0" aria-expanded="false" aria-controls="rating-container-desktop">
                    <span aria-hidden="true" class="icon docon docon-dislike"></span>
                    <span>否</span>
                </button>
            </div>
        </div>
        <form class="feedback-verbatim-form is-hidden" id="rating-container-desktop">
            <div class="verbatim-textarea box is-relative has-box-shadow-none has-border has-margin-top-small has-padding-extra-small is-size-extra-small">
                <label for="rating-textarea-desktop" class="visually-hidden">还有其他反馈吗？</label>
                <textarea id="rating-textarea-desktop" rows="4" maxlength="999" placeholder="还有其他反馈吗？" required="" class="textarea has-border-none has-box-shadow-none has-inner-focus"></textarea>
            </div>
            <div class="buttons is-right has-margin-top-medium has-margin-right-extra-small">
                <button class="skip-rating button is-transparent has-text-primary is-small has-border-none" type="button">跳过</button>
                <button class="submit-rating button is-primary is-small" data-bi-name="rating-verbatim" disabled="" type="submit">提交</button>
            </div>
        </form>
    </div>
    <div class="thankyou-rating is-hidden" tabindex="-1">
        <p>谢谢。</p>
    </div>
</div>									</div>
						<!-- end page rating section -->


						<!-- recommendations section -->
						<!-- end recommendations section -->

						<!-- feedback section -->
<section class="feedback-section is-relative" data-bi-name="feedback-section">

    <h2 id="feedback" class="title is-3 has-margin-top-large">反馈</h2>

    <div class="alert choose-feedback-type">
        <p aria-hidden="true" id="send-feedback-about">提交和查看相关反馈</p>

        <div class="choose-feedback-buttons has-margin-top-medium">
                <a class="button has-external-link-indicator feedback-type-product has-margin-bottom-small" aria-label="发送有关此产品的反馈" href="https://aka.ms/feedback/report?space=61" data-bi-name="product-feedback">
                    <span>此产品</span>
                </a>

			<a class="button feedback-type-product has-margin-bottom-small github-link" aria-label="发送有关此页面的反馈" data-bi-name="create-issue-on-github" href="https://github.com/dotnet/docs.zh-cn/issues/new?title=&amp;body=%0A%0A%5B%E5%9C%A8%E6%AD%A4%E5%A4%84%E8%BE%93%E5%85%A5%E5%8F%8D%E9%A6%88%5D%0A%0A%0A---%0A%23%23%23%23%20%E6%96%87%E6%A1%A3%E8%AF%A6%E7%BB%86%E4%BF%A1%E6%81%AF%0A%0A%E2%9A%A0%20*%E8%AF%B7%E5%8B%BF%E7%BC%96%E8%BE%91%E6%AD%A4%E9%83%A8%E5%88%86%E3%80%82%20docs.microsoft.com%20%E2%9E%9F%20GitHub%20%E9%97%AE%E9%A2%98%E9%93%BE%E6%8E%A5%E5%BF%85%E9%A1%BB%E5%85%B7%E6%9C%89%E6%AD%A4%E9%83%A8%E5%88%86%E3%80%82*%0A%0A*%20ID%3A%2006023407-704f-0ace-e89a-eedd9f95a007%0A*%20Version%20Independent%20ID%3A%20f25a6e1a-cb10-867b-0522-a377bf9d016b%0A*%20Content%3A%20%5B%E4%BD%BF%E7%94%A8%E6%8F%92%E4%BB%B6%E5%88%9B%E5%BB%BA%20.NET%20Core%20%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%20-%20.NET%5D(https%3A%2F%2Fdocs.microsoft.com%2Fzh-cn%2Fdotnet%2Fcore%2Ftutorials%2Fcreating-app-with-plugin-support)%0A*%20Content%20Source%3A%20%5Bdocs%2Fcore%2Ftutorials%2Fcreating-app-with-plugin-support.md%5D(https%3A%2F%2Fgithub.com%2Fdotnet%2Fdocs.zh-cn%2Fblob%2Flive%2Fdocs%2Fcore%2Ftutorials%2Fcreating-app-with-plugin-support.md)%0A*%20Product%3A%20**dotnet-fundamentals**%0A*%20GitHub%20Login%3A%20%40jkoritzinsky%0A*%20Microsoft%20Alias%3A%20**jekoritz**">
				<span aria-hidden="true" class="docon docon-brand-github has-padding-right-extra-small"></span>
				<span>此页面</span>
			</a>
        </div>
    </div>

    <div class="action-container is-flex has-flex-justify-content-end has-margin-top-small has-margin-bottom-small">
        <a class="view-on-github has-external-link-indicator" data-bi-name="view-on-github" href="https://github.com/dotnet/docs.zh-cn/issues?utf8=%E2%9C%93&amp;q=%22f25a6e1a-cb10-867b-0522-a377bf9d016b%22&amp;in=body">
            <span aria-hidden="true" class="docon docon-brand-github"></span>
            <span>查看所有页面反馈</span>
        </a>
    </div>
</section>
						<!-- end feedback section -->

						<!-- feedback report section -->
						<!-- end feedback report section -->

						<div class="footerContainer is-visible-interactive has-default-focus ">



	<footer id="footer-interactive" data-bi-name="footer" class="footer-layout">

    <div class="is-flex is-full-height has-padding-right-extra-large-desktop">
			<a data-mscc-ic="false" class="locale-selector-link has-flex-shrink-none" href="https://docs.microsoft.com/zh-cn/locale?target=https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support" data-bi-name="select-locale"><span class="icon docon docon-world is-size-large has-margin-right-small" aria-hidden="true"></span><span class="local-selector-link-text">中文 (简体)</span></a>
		<div class="has-margin-left-medium has-margin-right-medium has-flex-shrink-none">
<div class="dropdown has-caret-up">
	<button class="dropdown-trigger button is-transparent is-small is-icon-only-touch has-inner-focus theme-dropdown-trigger" aria-controls="theme-menu-interactive" aria-expanded="false" title="主题" data-bi-name="theme">
		<span class="icon">
			<span class="docon docon-sun" aria-hidden="true"></span>
		</span>
		<span>主题</span>
	</button>
	<div class="dropdown-menu" id="theme-menu-interactive" role="menu">
		<ul class="theme-selector has-padding-small">
			<li class="theme is-block">
				<button class="button is-text is-small theme-control is-fullwidth has-flex-justify-content-start is-selected" data-theme-to="light" aria-pressed="true">
					<span class="theme-light has-margin-right-small">
						<span class="theme-selector-icon css-variable-support has-border is-inline-block has-body-background" aria-hidden="true">
							<svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 14">
								<rect width="22" height="14" class="has-fill-body-background"></rect>
								<rect x="5" y="5" width="12" height="4" class="has-fill-secondary"></rect>
								<rect x="5" y="2" width="2" height="1" class="has-fill-secondary"></rect>
								<rect x="8" y="2" width="2" height="1" class="has-fill-secondary"></rect>
								<rect x="11" y="2" width="3" height="1" class="has-fill-secondary"></rect>
								<rect x="1" y="1" width="2" height="2" class="has-fill-secondary"></rect>
								<rect x="5" y="10" width="7" height="2" rx="0.3" class="has-fill-primary"></rect>
								<rect x="19" y="1" width="2" height="2" rx="1" class="has-fill-secondary"></rect>
							</svg>
						</span>
					</span>
					<span role="menuitem">
亮					</span>
				</button>
			</li>
			<li class="theme is-block">
				<button class="button is-text is-small theme-control is-fullwidth has-flex-justify-content-start" data-theme-to="dark" aria-pressed="false">
					<span class="theme-dark has-margin-right-small">
						<span class="has-border theme-selector-icon css-variable-support is-inline-block has-body-background" aria-hidden="true">
							<svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 14">
								<rect width="22" height="14" class="has-fill-body-background"></rect>
								<rect x="5" y="5" width="12" height="4" class="has-fill-secondary"></rect>
								<rect x="5" y="2" width="2" height="1" class="has-fill-secondary"></rect>
								<rect x="8" y="2" width="2" height="1" class="has-fill-secondary"></rect>
								<rect x="11" y="2" width="3" height="1" class="has-fill-secondary"></rect>
								<rect x="1" y="1" width="2" height="2" class="has-fill-secondary"></rect>
								<rect x="5" y="10" width="7" height="2" rx="0.3" class="has-fill-primary"></rect>
								<rect x="19" y="1" width="2" height="2" rx="1" class="has-fill-secondary"></rect>
							</svg>
						</span>
					</span>
					<span role="menuitem">
暗					</span>
				</button>
			</li>
			<li class="theme is-block">
				<button class="button is-text is-small theme-control is-fullwidth has-flex-justify-content-start" data-theme-to="high-contrast" aria-pressed="false">
					<span class="theme-high-contrast has-margin-right-small">
						<span class="has-border theme-selector-icon css-variable-support is-inline-block has-body-background" aria-hidden="true">
							<svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 14">
								<rect width="22" height="14" class="has-fill-body-background"></rect>
								<rect x="5" y="5" width="12" height="4" class="has-fill-secondary"></rect>
								<rect x="5" y="2" width="2" height="1" class="has-fill-secondary"></rect>
								<rect x="8" y="2" width="2" height="1" class="has-fill-secondary"></rect>
								<rect x="11" y="2" width="3" height="1" class="has-fill-secondary"></rect>
								<rect x="1" y="1" width="2" height="2" class="has-fill-secondary"></rect>
								<rect x="5" y="10" width="7" height="2" rx="0.3" class="has-fill-primary"></rect>
								<rect x="19" y="1" width="2" height="2" rx="1" class="has-fill-secondary"></rect>
							</svg>
						</span>
					</span>
					<span role="menuitem">
高对比度					</span>
				</button>
			</li>
		</ul>
	</div>
</div>		</div>
	</div>
    <ul class="links" data-bi-name="footerlinks">
		<li class="manage-cookies-holder" hidden=""></li>
			<li><a data-mscc-ic="false" href="https://docs.microsoft.com/zh-cn/previous-versions/" data-bi-name="archivelink">旧版文档</a></li>
			<li><a data-mscc-ic="false" href="https://docs.microsoft.com/zh-cn/teamblog" data-bi-name="bloglink">博客</a></li>
			<li><a data-mscc-ic="false" href="https://docs.microsoft.com/zh-cn/contribute" data-bi-name="contributorGuide">参与</a></li>
				<li><a data-mscc-ic="false" href="https://go.microsoft.com/fwlink/?LinkId=521839" data-bi-name="privacy">隐私和 Cookie</a></li>
			<li><a data-mscc-ic="false" href="https://docs.microsoft.com/zh-cn/legal/termsofuse" data-bi-name="termsofuse">使用条款</a></li>
				<li><a data-mscc-ic="false" href="https://aka.ms/sitefeedback" data-bi-name="feedback">网站反馈</a></li>
			<li><a data-mscc-ic="false" href="https://www.microsoft.com/en-us/legal/intellectualproperty/Trademarks/EN-US.aspx" data-bi-name="trademarks">商标</a></li>
		<li>© Microsoft 2021</li>
    </ul>
</footer>
						</div>
					</div>

					<div class="is-size-small right-container column is-one-quarter is-one-fifth-desktop is-hidden-mobile is-hidden-tablet-only" data-bi-name="pageactions" role="complementary" aria-label="页面操作">
						<div id="affixed-right-container" class="doc-outline is-fixed is-vertically-scrollable" style="width: 172.938px; top: 166px; bottom: 24px;">
								
	
	

	<div class="feedback-verbatim has-border-bottom has-padding-bottom-small has-margin-bottom-small" data-bi-name="rating">
    <div class="binary-rating">
        <div class="binary-rating-buttons">

				<h3 class="has-text-weight-semibold has-margin-top-none has-margin-bottom-small">此页面有帮助吗?</h3>
			<div>
                <button class="thumb-rating like has-inner-focus" title="是" data-bi-name="rating-yes" aria-expanded="false" data-bi-sat="1" aria-controls="rating-container-mobile">
                    <span aria-hidden="true" class="icon docon docon-like"></span>
                    <span>是</span>
                </button>
                <button class="thumb-rating dislike has-inner-focus" title="否" data-bi-name="rating-no" data-bi-sat="0" aria-expanded="false" aria-controls="rating-container-mobile">
                    <span aria-hidden="true" class="icon docon docon-dislike"></span>
                    <span>否</span>
                </button>
            </div>
        </div>
        <form class="feedback-verbatim-form is-hidden" id="rating-container-mobile">
            <div class="verbatim-textarea box is-relative has-box-shadow-none has-border has-margin-top-small has-padding-extra-small is-size-extra-small">
                <label for="rating-textarea-mobile" class="visually-hidden">还有其他反馈吗？</label>
                <textarea id="rating-textarea-mobile" rows="4" maxlength="999" placeholder="还有其他反馈吗？" required="" class="textarea has-border-none has-box-shadow-none has-inner-focus"></textarea>
            </div>
            <div class="buttons is-right has-margin-top-medium has-margin-right-extra-small">
                <button class="skip-rating button is-transparent has-text-primary is-small has-border-none" type="button">跳过</button>
                <button class="submit-rating button is-primary is-small" data-bi-name="rating-verbatim" disabled="" type="submit">提交</button>
            </div>
        </form>
    </div>
    <div class="thankyou-rating is-hidden" tabindex="-1">
        <p>谢谢。</p>
    </div>
</div>							<nav id="side-doc-outline" data-bi-name="intopic toc" role="navigation" aria-label="文章大纲">
								<h3>本文内容</h3>
							<ol><li class="selected"><a href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#prerequisites">系统必备</a></li><li><a href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#create-the-application">创建应用程序</a></li><li><a href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#create-the-plugin-interfaces">创建插件接口</a></li><li><a href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#load-plugins">加载插件</a></li><li><a href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#simple-plugin-with-no-dependencies">不具有依赖项的简单插件</a></li><li><a href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#plugin-with-library-dependencies">具有库依赖项的插件</a></li><li><a href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#other-examples-in-the-sample">示例中的其他示例</a></li><li><a href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#reference-a-plugin-interface-from-a-nuget-package">从 NuGet 包引用插件接口</a></li><li><a href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#plugin-target-framework-recommendations">插件目标框架建议</a></li><li><a href="https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#plugin-framework-references">插件框架引用</a></li></ol></nav>
						</div>
					</div>

					<!--end of div.columns -->
				</div>

			<!--end of .primary-holder -->
			</section>

			<aside id="interactive-container" class="interactive-container is-visible-interactive column has-body-background-dark ">
			</aside>
		</div>

		<!--end of .mainContainer -->
	</div>

	<div class="footerContainer has-default-focus is-hidden-interactive ">



	<footer id="footer" data-bi-name="footer" class="footer-layout uhf-container has-padding" role="contentinfo">

    <div class="is-flex is-full-height has-padding-right-extra-large-desktop">
			<a data-mscc-ic="false" class="locale-selector-link has-flex-shrink-none" href="https://docs.microsoft.com/zh-cn/locale?target=https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support" data-bi-name="select-locale"><span class="icon docon docon-world is-size-large has-margin-right-small" aria-hidden="true"></span><span class="local-selector-link-text">中文 (简体)</span></a>
		<div class="has-margin-left-medium has-margin-right-medium has-flex-shrink-none">
<div class="dropdown has-caret-up">
	<button class="dropdown-trigger button is-transparent is-small is-icon-only-touch has-inner-focus theme-dropdown-trigger" aria-controls="theme-menu" aria-expanded="false" title="主题" data-bi-name="theme">
		<span class="icon">
			<span class="docon docon-sun" aria-hidden="true"></span>
		</span>
		<span>主题</span>
	</button>
	<div class="dropdown-menu" id="theme-menu" role="menu">
		<ul class="theme-selector has-padding-small">
			<li class="theme is-block">
				<button class="button is-text is-small theme-control is-fullwidth has-flex-justify-content-start is-selected" data-theme-to="light" aria-pressed="true">
					<span class="theme-light has-margin-right-small">
						<span class="theme-selector-icon css-variable-support has-border is-inline-block has-body-background" aria-hidden="true">
							<svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 14">
								<rect width="22" height="14" class="has-fill-body-background"></rect>
								<rect x="5" y="5" width="12" height="4" class="has-fill-secondary"></rect>
								<rect x="5" y="2" width="2" height="1" class="has-fill-secondary"></rect>
								<rect x="8" y="2" width="2" height="1" class="has-fill-secondary"></rect>
								<rect x="11" y="2" width="3" height="1" class="has-fill-secondary"></rect>
								<rect x="1" y="1" width="2" height="2" class="has-fill-secondary"></rect>
								<rect x="5" y="10" width="7" height="2" rx="0.3" class="has-fill-primary"></rect>
								<rect x="19" y="1" width="2" height="2" rx="1" class="has-fill-secondary"></rect>
							</svg>
						</span>
					</span>
					<span role="menuitem">
亮					</span>
				</button>
			</li>
			<li class="theme is-block">
				<button class="button is-text is-small theme-control is-fullwidth has-flex-justify-content-start" data-theme-to="dark" aria-pressed="false">
					<span class="theme-dark has-margin-right-small">
						<span class="has-border theme-selector-icon css-variable-support is-inline-block has-body-background" aria-hidden="true">
							<svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 14">
								<rect width="22" height="14" class="has-fill-body-background"></rect>
								<rect x="5" y="5" width="12" height="4" class="has-fill-secondary"></rect>
								<rect x="5" y="2" width="2" height="1" class="has-fill-secondary"></rect>
								<rect x="8" y="2" width="2" height="1" class="has-fill-secondary"></rect>
								<rect x="11" y="2" width="3" height="1" class="has-fill-secondary"></rect>
								<rect x="1" y="1" width="2" height="2" class="has-fill-secondary"></rect>
								<rect x="5" y="10" width="7" height="2" rx="0.3" class="has-fill-primary"></rect>
								<rect x="19" y="1" width="2" height="2" rx="1" class="has-fill-secondary"></rect>
							</svg>
						</span>
					</span>
					<span role="menuitem">
暗					</span>
				</button>
			</li>
			<li class="theme is-block">
				<button class="button is-text is-small theme-control is-fullwidth has-flex-justify-content-start" data-theme-to="high-contrast" aria-pressed="false">
					<span class="theme-high-contrast has-margin-right-small">
						<span class="has-border theme-selector-icon css-variable-support is-inline-block has-body-background" aria-hidden="true">
							<svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 14">
								<rect width="22" height="14" class="has-fill-body-background"></rect>
								<rect x="5" y="5" width="12" height="4" class="has-fill-secondary"></rect>
								<rect x="5" y="2" width="2" height="1" class="has-fill-secondary"></rect>
								<rect x="8" y="2" width="2" height="1" class="has-fill-secondary"></rect>
								<rect x="11" y="2" width="3" height="1" class="has-fill-secondary"></rect>
								<rect x="1" y="1" width="2" height="2" class="has-fill-secondary"></rect>
								<rect x="5" y="10" width="7" height="2" rx="0.3" class="has-fill-primary"></rect>
								<rect x="19" y="1" width="2" height="2" rx="1" class="has-fill-secondary"></rect>
							</svg>
						</span>
					</span>
					<span role="menuitem">
高对比度					</span>
				</button>
			</li>
		</ul>
	</div>
</div>		</div>
	</div>
    <ul class="links" data-bi-name="footerlinks">
		<li class="manage-cookies-holder" hidden=""></li>
			<li><a data-mscc-ic="false" href="https://docs.microsoft.com/zh-cn/previous-versions/" data-bi-name="archivelink">旧版文档</a></li>
			<li><a data-mscc-ic="false" href="https://docs.microsoft.com/zh-cn/teamblog" data-bi-name="bloglink">博客</a></li>
			<li><a data-mscc-ic="false" href="https://docs.microsoft.com/zh-cn/contribute" data-bi-name="contributorGuide">参与</a></li>
				<li><a data-mscc-ic="false" href="https://go.microsoft.com/fwlink/?LinkId=521839" data-bi-name="privacy">隐私和 Cookie</a></li>
			<li><a data-mscc-ic="false" href="https://docs.microsoft.com/zh-cn/legal/termsofuse" data-bi-name="termsofuse">使用条款</a></li>
				<li><a data-mscc-ic="false" href="https://aka.ms/sitefeedback" data-bi-name="feedback">网站反馈</a></li>
			<li><a data-mscc-ic="false" href="https://www.microsoft.com/en-us/legal/intellectualproperty/Trademarks/EN-US.aspx" data-bi-name="trademarks">商标</a></li>
		<li>© Microsoft 2021</li>
    </ul>
</footer>
	</div>

		<script type="text/x-mathjax-config;executed=true">
			MathJax.Hub.Config({
				showMathMenu: false,
				showMathMenuMSIE: false,
				tex2jax: {
					inlineMath: [['$','$'], ['\\(','\\)']],
					processEscapes: true
				}
			});
			MathJax.Hub.Register.StartupHook("End", function () {
				document.documentElement.classList.add('mathjax-complete');
			});
		</script>
		<script src="./使用插件创建 .NET Core 应用程序 - .NET _ Microsoft Docs_files/MathJax.js.下载" integrity="sha384-RLsAi7wiVvnmHrRjlVvUjU45C0bfsIBg6Gsxue6azjJi+lA5q5uK+XbGzO3yn5g1" crossorigin="anonymous"></script>
	<div id="action-panel" role="region" aria-label="操作面板" class="action-panel has-default-focus" tabindex="-1"></div>


</body></html>